This error is supposed to be fixed in 4.2.2.Final (see https://hibernate.atlassian.net/browse/HHH-8226), but I am still getting a Missing Column error when Hibernate tries to validate my schema. Here is my dataSource and sessionFactory defined in Spring (3.2.1):
Code:
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="${jdbc.driverClassName}" />
<property name="jdbcUrl" value="${jdbc.url}" />
<property name="user" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
<property name="initialPoolSize" value="${jdbc.initialPoolSize}" />
<property name="minPoolSize" value="${jdbc.minPoolSize}" />
<property name="maxPoolSize" value="${jdbc.maxPoolSize}" />
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="namingStrategy" ref="namingStrategy" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
<prop key="hibernate.hbm2ddl.auto">validate</prop>
<prop key="hibernate.synonyms">true</prop>
<prop key="hibernate.flushMode">AUTO</prop>
</props>
</property>
<property name="packagesToScan" value="com.mycompany.model" />
</bean>
Here is some log output I'm seeing:
INFO : 06-19-2013 16:14:59 TableMetadata - HHH000261: Table found: myschema.mysynonym
INFO : 06-19-2013 16:14:59 TableMetadata - HHH000037: Columns: []...
Caused by: org.hibernate.HibernateException: Missing column: serial_number in myschema.mysynonym
at org.hibernate.mapping.Table.validateColumns(Table.java:366)
at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:1284)
at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:155)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:508)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1769)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1840)
at org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSessionFactory(LocalSessionFactoryBuilder.java:242)
at org.springframework.orm.hibernate4.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:372)
at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:357)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1545)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1483)
... 107 more
It seems that it's unable to find any columns of my synonym based on the output above. My synonym points to a view in another database but I wouldn't think this makes any difference. Can anyone offer up any thoughts on what might be happening?