当前位置: 代码迷 >> Java Web开发 >> 在 Hibernate3 查询不到 Oracle 11g 里的记录
  详细解决方案

在 Hibernate3 查询不到 Oracle 11g 里的记录

热度:1887   发布时间:2013-02-25 21:17:19.0
求助在 Hibernate3 查询不到 Oracle 11g 里的记录
以前开的项目使用mysql可以运行,但现在改成Oracle 11g的,在用HQL查询数据时返回的总是0记录,在后台直接将结果打印也是0
System.out.println( this.tuserManager.load().size());
请问这是怎么回事
配置如下:
驱动为classes12.jar、ojdbc5.jar、ojdbc6.jar都用过,都不行

jdbc.properties:
jdbc.driverClassName=oracle.jdbc.driver.OracleDriver
jdbc.url=jdbc:oracle:thin:@localhost:1521:ORCL
jdbc.username=system
jdbc.password=alerik

<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<value>classpath:jdbc.properties</value>
</property>
</bean>

<bean id="dataSource" destroy-method="close"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"
value="${jdbc.driverClassName}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>

<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.OracleDialect
</prop>
  <prop key="hibernate.show_sql">true</prop>
</props>
</property>
数据库:
create table tuser
(
  userid number(10) not null,
  username varchar2(4),
  userpassword varchar2(4),  
  primary key (userid)
);
Model:

@Entity
public class Tuser {
private int userid;
private String username;
private String userpassword;

@Id
public int getUserid() {
return userid;
}

public void setUserid(int userid) {
this.userid = userid;
}

public String getUserpassword() {
return userpassword;
}

public void setUserpassword(String userpassword) {
this.userpassword = userpassword;
}

public String getUsername() {
return username;
}

public void setUsername(String username) {
this.username = username;
}

运行是没有任何错误,但Tomcat启动时有如下错误
15:12:43,953 WARN Oracle9Dialect:60 - The Oracle9Dialect dialect has been deprecated; use either Or
acle9iDialect or Oracle10gDialect instead
15:12:43,953 WARN OracleDialect:49 - The OracleDialect dialect has been deprecated; use Oracle8iDia
lect instead
其它都正常。
操作语言为:
public List<Tuser> getUsers(String condition) {
return hibernateTemplate.find("from Tuser t ");
}

------解决方案--------------------------------------------------------
org.hibernate.dialect.OracleDialect换为org.hibernate.dialect.Oracle10gDialect试试看
  相关解决方案