从 Spring LocalSessionFactoryBean 获取 table 字段最大值
Get table field max value from Spring LocalSessionFactoryBean
我的 table 中有一个字段定义为:
"SECTION" NUMBER(3,0)
该字段的 hbm 映射是:
<property name="section" type="integer">
<column name="SECTION" />
</property>
在实体 class 中,我将其声明为:
private Integer section;
在我的 DAO 中,在插入数据之前,如果我得到的数据对于部分字段而言太大,我想验证并抛出异常。
到目前为止,我使用从我的应用程序上下文中获得的 LocalSessionFactoryBean 得到的结果:
int length = ((Column) localSessionFactoryBean.
getConfiguration().
getClassMapping(MyEntity.class.getName()).
getProperty("section").
getColumnIterator().next()).getLength();
问题是对于声明为整数的每个字段,长度始终为 255。
如何获取oracle中定义的列长度? (此处:数字(3,0))
也许,而不是尝试访问列定义,只需在您的 POJO 上使用 Hibernate Validator?
我的 table 中有一个字段定义为:
"SECTION" NUMBER(3,0)
该字段的 hbm 映射是:
<property name="section" type="integer">
<column name="SECTION" />
</property>
在实体 class 中,我将其声明为:
private Integer section;
在我的 DAO 中,在插入数据之前,如果我得到的数据对于部分字段而言太大,我想验证并抛出异常。
到目前为止,我使用从我的应用程序上下文中获得的 LocalSessionFactoryBean 得到的结果:
int length = ((Column) localSessionFactoryBean.
getConfiguration().
getClassMapping(MyEntity.class.getName()).
getProperty("section").
getColumnIterator().next()).getLength();
问题是对于声明为整数的每个字段,长度始终为 255。
如何获取oracle中定义的列长度? (此处:数字(3,0))
也许,而不是尝试访问列定义,只需在您的 POJO 上使用 Hibernate Validator?