富贵资源网 Design By www.hznty.com
通过valuelist的queryMap传递过来的参数默认都为string类型,在valuelist配置文件的hql中,如果直接将该值赋给整型的字段会报错。一般我们会在hql中利用转型函数来进行处理,如下:
复制代码 代码如下:
<entry key="areasInfoAdapter">
<bean parent="abstractHibernate30Adapter">
<property name="defaultNumberPerPage"><value>19</value></property>
<property name="statementBuilder"><ref bean="statementBuilderHql"/></property>
<property name="defaultSortColumn"><value>id</value></property>
<property name="defaultSortDirection"><value>desc</value></property>
<property name="hql">
<value>
from com.berheley.hcms.persistence.model.TBaseAreas as tb
where tb.status='1'
/~hId : and tb.hId = to_number{hId} ~/
/~oId : and tb.oId = to_number{oId} ~/
order by tb.code asc
</value>
</property>
<property name="defaultFocusPropertyObjectAlias"><value>vo</value></property>
<property name="maxRowsForFocus"><value>160000</value></property>
<property name="removeEmptyStrings"><value>true</value></property>
</bean>
</entry>
该方法比较麻烦,在所有的整型字段地方都需要添加函数处理,并且进行数据库迁移时会出现函数不兼容的问题。可以利用ValueList配置来对整型的字段进行统一设置,valuelist在拼装sql前会对配置好的参数进行转型。如下:
复制代码 代码如下:
<bean id="integerSetterHql" class="net.mlw.vlh.adapter.hibernate3.util.setter.IntegerSetter"></bean>
<bean id="statementBuilderHql" class="net.mlw.vlh.adapter.hibernate3.util.StatementBuilder">
<property name="setters">
<map>
<entry key="uId"><ref bean="integerSetterHql"/></entry>
<entry key="oId"><ref bean="integerSetterHql"/></entry>
</map>
</property>
</bean>
复制代码 代码如下:
<entry key="areasInfoAdapter">
<bean parent="abstractHibernate30Adapter">
<property name="defaultNumberPerPage"><value>19</value></property>
<property name="statementBuilder"><ref bean="statementBuilderHql"/></property>
<property name="defaultSortColumn"><value>id</value></property>
<property name="defaultSortDirection"><value>desc</value></property>
<property name="hql">
<value>
from com.berheley.hcms.persistence.model.TBaseAreas as tb
where tb.status='1'
/~hId : and tb.hId = to_number{hId} ~/
/~oId : and tb.oId = to_number{oId} ~/
order by tb.code asc
</value>
</property>
<property name="defaultFocusPropertyObjectAlias"><value>vo</value></property>
<property name="maxRowsForFocus"><value>160000</value></property>
<property name="removeEmptyStrings"><value>true</value></property>
</bean>
</entry>
该方法比较麻烦,在所有的整型字段地方都需要添加函数处理,并且进行数据库迁移时会出现函数不兼容的问题。可以利用ValueList配置来对整型的字段进行统一设置,valuelist在拼装sql前会对配置好的参数进行转型。如下:
复制代码 代码如下:
<bean id="integerSetterHql" class="net.mlw.vlh.adapter.hibernate3.util.setter.IntegerSetter"></bean>
<bean id="statementBuilderHql" class="net.mlw.vlh.adapter.hibernate3.util.StatementBuilder">
<property name="setters">
<map>
<entry key="uId"><ref bean="integerSetterHql"/></entry>
<entry key="oId"><ref bean="integerSetterHql"/></entry>
</map>
</property>
</bean>
富贵资源网 Design By www.hznty.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
富贵资源网 Design By www.hznty.com
暂无评论...