我正在尝试将应用程序数据库从mysql更改为oracle 11g。我在此应用程序中使用了休眠模式,但是休眠模式抛出了:
org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:90)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.loader.Loader.doList(Loader.java:2231)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2125)
at org.hibernate.loader.Loader.list(Loader.java:2120)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:312)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1722)
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:175)
下面是我的hibernate.cfg.xml文件:
*<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
<!-- <property name="hibernate.default_schema">wind</property> -->
<property name="show_sql">true</property>
<property name="hibernate.hbm2ddl.auto">validate</property>
<property name="hibernate.cache.use_second_level_cache">false</property>
<property name="hibernate.cache.use_query_cache">false</property>
<!-- <property name="connection.autoReconnect">true</property> -->
<!-- <property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">100</property>-->
<property name="hibernate.c3p0.timeout">25200</property>
<property name="hibernate.c3p0.max_statements">50</property>
<property name="hibernate.c3p0.idle_test_period">3000</property>*
我正在使用一个配置文件来获取数据库URL和ID密码。
DATABASE_URL=jdbc:oracle:thin:@localhost:1521/wind
DATABASE_USERNAME=appuser
DATABASE_PASSWORD=appuser
DATABASE_CONN_POOL_MIN=5
DATABASE_CONN_POOL_MAX=50
映射文件:
<hibernate-mapping>
<class name="com.nsn.abc.entity.UserInfo" table="user_info" >
<id name="id" type="java.lang.Integer">
<column name="id" />
<generator class="assigned" />
</id>
<property name="username" type="string">
<column name="username" length="30" not-null="true" unique="true" />
</property>
<property name="firstName" type="string">
<column name="first_name" length="30" not-null="true" />
</property>
<property name="lastname" type="string">
<column name="lastname" length="30" />
</property>
<property name="email" type="string">
<column name="email" length="50" />
</property>
<property name="password" type="string">
<column name="password" length="30" not-null="true" />
</property>
<property name="phoneNumber" type="string">
<column name="phone_number" length="30" />
</property>
<property name="rights" type="string">
<column name="rights" length="30" not-null="true" />
</property>
<property name="counter" type="int">
<column name="counter" not-null="true" />
</property>
<property name="role" type="string">
<column name="role" length="20" />
</property>
<property name="activeFlag" type="boolean">
<column name="active_flag" not-null="true" />
</property>
<property name="info" type="string">
<column name="info" length="45" />
</property>
<set name="massProvisioningHistories" table="mass_provisioning_history" inverse="true" lazy="true" fetch="select">
<key>
<column name="user_ref" not-null="true" />
</key>
<one-to-many class="com.nsn.abc.entity.MassProvisioningHistory" />
</set>
</class>
</hibernate-mapping>
我已经检查了所有配置和其他详细信息,但仍然没有任何进展。 它抛出 SQL错误:923,SQLState:42000 。 使用ORA-00923:找不到预期的FROM关键字 在日志中,其生成如下查询: 休眠状态:选择userinfo0_.id作为id25_,userinfo0_.username作为username25_,userinfo0_.first_name作为first3_25_,userinfo0_.lastname作为lastname25_,userinfo0_.email作为email25_,userinfo0_.password作为password25_,userinfo0_.phone_number作为phone7_25。权限为right25_,userinfo0_.counter为counter25_,userinfo0_.role为role25_,userinfo0_.active_flag为active11_25_,userinfo0_.info作为info25_ from user_info userinfo0_ from其中userinfo0_.username =?
请提出建议。
致谢, skr
答案 0 :(得分:0)
在应用程序中,我们使用SELECT 1来检查休眠连接。
MySql支持“ SELECT 1”,但是在oracle中,我们需要提及“来自Dual的SELECT 1”。
现在可以正常工作了。
感谢帮助。