According to configuration, Hibernate DAO repository should send query like this:
INSERT INTO some_schema.some_table (...) VALUES (...)
Instead, Hibernate sends this:
INSERT INTO some_table (...) VALUES (...)
It omits schema prefix. Without that prefix I am getting ORA-00942, table does not exist Oracle database error. How to force Hibernate send schema prefix?
P.S. This question is similar to this question, but adding default schema doesn't work for me, because I am using more of them.
Configuration of entity is like this:
<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 config:
<?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>