[color=#FF0000][b]软件环境配置:[/b][/color]Spring2.5+struts2.1+Hibernate3.1+oracle11g
[color=#FF0000][b]问题:[/b][/color]
一个查询的方法,通过hql拼接实现动态查询。在实现按编号查询的时候出现了这样的奇葩问题。。。。
数据库里编号是主键,varchar类型,持久化类对应字段String类型,编号如:0101,0102,0103....0205,0306
在查询0108和0109时报错,其余正常。。。单元测试和tomcat中是一样的结果。不能查询0108和0109。
[b][color=#FF0000]以下是查询 0109 时控制台报错:[/color][/b]
[b][color=#FF0000]以下是查询 0107 时控制的查询结果:[/color][/b]
[b][color=#FF0000]查询0107时,自动生成的sql代码:[/color][/b]
SQL: select rooms0_.ID as col_0_0_, types1_.NAME as col_1_0_, types1_.ROOMSIZE as col_2_0_, types1_.DPRICE as col_3_0_, types1_.HPRICE as col_4_0_, types1_.DEPOSIT as col_5_0_ from ADMIN5.ROOMS rooms0_, ADMIN5.TYPES types1_ where rooms0_.TYPE_ID=types1_.ID and rooms0_.STATE=1 and rooms0_.ID=[size=18px][color=#FF0000]107[/color][/size] order by types1_.ID, rooms0_.ID
[color=#0000FF][size=24px]这里自动转化成了107????为什么啊???那为什么查询0109和0108不自动转换呢?反而说session已经关闭???[/size][/color]
[color=#FF0000][b]java代码:[/b][/color]
[img=http://img.bbs.csdn.net/upload/201608/18/1471518802_118168.png][/img]
[b][color=#FF0000]Spring(代理了hibernate的sessionFactory)代码:[/color][/b]
<?xml version="1.0" encoding="UTF-8"?>
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd ">
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"
value="oracle.jdbc.driver.OracleDriver">
</property>
<property name="url"
value="jdbc:oracle:thin:@localhost:1521:ORCL">
</property>
<property name="username" value="xxxxxxx"></property>
<property name="password" value="xxxxxxx"></property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.Oracle9Dialect
</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/accp/entity/Checkin.hbm.xml</value>
<value>com/accp/entity/Rooms.hbm.xml</value>
<value>com/accp/entity/Admin.hbm.xml</value>
<value>com/accp/entity/Reserve.hbm.xml</value>
<value>com/accp/entity/Types.hbm.xml</value>
<value>com/accp/entity/Orders.hbm.xml</value></list>
</property></bean>
<!-- 自动扫描包 -->
<context:component-scan base-package="com.xxx"></context:component-scan>
<!-- 引入事务管理器类 -->
<bean class="org.springframework.orm.hibernate3.HibernateTransactionManager" id="tranManger">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<!-- 事务注解 -->
<tx:annotation-driven transaction-manager="tranManger"/>