hibernate.hbm2ddl.auto does not respect location of domain object
-----------------------------------------------------------------
Key: HHH-7140
URL:
https://hibernate.onjira.com/browse/HHH-7140
Project: Hibernate ORM
Issue Type: Bug
Components: core
Affects Versions: 3.6.9
Environment: MSSQL Server, Spring 3.1
Reporter: Thomas Wabner
I have some domain objects (with javax.persistence Entity annotations) where some of them
connected to one and some to another database. Let me introduce a small example:
package one;
@Entity
@Table(name="objOne")
public class DomainObjOne {
}
....
package two;
@Entity
@Table(name="objTwo")
public class DomainObjTwo {
}
Now I have following sort of spring configuration:
<jee:jndi-lookup id="dataSourceDirect" jndi-name="jdbc/one" />
<!-- decorate data source with JDBC logging -->
<bean id="dataSource"
class="org.jdbcdslog.ConnectionPoolDataSourceProxy">
<property name="targetDSDirect" ref="dataSourceDirect" />
</bean>
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan" value="one" />
<property name="jpaVendorAdapter">
<bean
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql" value="false" />
<property name="generateDdl" value="true" />
<property name="databasePlatform"
value="my.persistence.hibernate.OptimizedMSSQLServerDialect" />
</bean>
</property>
</bean>
<jee:jndi-lookup id="twoDataSourceDirect" jndi-name="jdbc/two"
/>
<bean id="pmdDataSource"
class="org.jdbcdslog.ConnectionPoolDataSourceProxy">
<property name="targetDSDirect" ref="twoDataSourceDirect"
/>
</bean>
<bean id="pmdEntityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="twoDataSource" />
<property name="packagesToScan" value="two" />
<property name="jpaVendorAdapter">
<bean id="hibernateJpaVendorAdapter"
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql" value="false" />
<property name="generateDdl" value="false" />
<property name="databasePlatform"
value="my.persistence.hibernate.OptimizedMSSQLServerDialect" />
</bean>
</property>
</bean>
---------------
Now I try to start my spring context ... I would expect, that all entities from package
"one" are updated, because there I have set generateDdl=true ... and all
entities from package "two" are not used in update / ignored.
But I get some SQL exceptions, because hibernate tried to update my entity from package
"two" in the database configured for package "one".
I see in my log (debug level), that
org.hibernate.cfg.Configuration - resolving reference to class: one.DomainObjOne
is included and two.DomainObjTwo not (which seems correct).
But while the schema update is running I get the information:
INFO o.h.tool.hbm2ddl.DatabaseMetadata - table not found: OBJ_TWO
For me, the correct behavior should be to ignore the table / entity for domain object two
because for this object no update was defined.
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira