根據配置,Hibernate的DAO庫應該把這樣的查詢:Hibernate不包括架構到查詢
INSERT INTO some_schema.some_table (...) VALUES (...)
相反,休眠發送此:
INSERT INTO some_table (...) VALUES (...)
它省略了模式前綴。沒有那個前綴我得到ORA-00942,表不存在Oracle數據庫錯誤。如何強制Hibernate發送模式前綴?
P.S.此問題與this question類似,但添加默認模式對我無效,因爲我使用了更多的模式。實體
配置是這樣的:
<hibernate-mapping>
<class name="com.somepackage.SomeClass" table="some_table" schema="some_schema">
<id name="someID" type="int" column="SOME_TABLE_ID">
<generator class="increment"/>
</id>
<property name="someProp" column="SOME_PROP" type="string"/>
</class>
</hibernate-mapping>
Hibernate的配置:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<!-- Oracle data source definition -->
<bean id="oracleDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName"><value>${oracle.database.driverClassName}</value></property>
<property name="url"><value>${oracle.database.url}</value></property>
<property name="username"><value>${oracle.database.username}</value></property>
<property name="password"><value>${oracle.database.password}</value></property>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="oracleDataSource" />
<property name="mappingResources">
<list>
<value>some-table.cfg.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.current_session_context_class">thread</prop>
</props>
</property>
</bean>
請顯示您的休眠配置文件 –
@SatishPahuja這裏是休眠配置。 – milosdju