0

I have an @Entity class in which there is an instance like this

@Column(name="some_column_in_table", precision=3, scale=1)
    private BigDecimal someColumnInTable;

How can I get precision of that instance?

वरुण
  • 1,237
  • 3
  • 18
  • 50

2 Answers2

1

I'm not quite sure if i got your problem correctly, but have you tried

 someColumnInTable.precision()

as told by the BigDecimal JavaDoc?

Steffen
  • 341
  • 1
  • 12
1

http://docs.oracle.com/javaee/5/api/javax/persistence/Column.html If You just want to programatically get the value set in the annotation, You can do it. The retention for Column is set to RUNTIME, so using Reflection it is possible.

Field f = MyClass.class.getDeclaredField("someColumnInTable")) { 
Column column = f.getAnnotation(Column.class);
if (column != null){
   System.out.println(column.precision());
}

Here are some other examples how to do it: Is it possible to read the value of a annotation in java?

Community
  • 1
  • 1
maslan
  • 2,078
  • 16
  • 34