samedi 21 février 2015

Integrating existing hibernate functionality into Grails

My coworker and I inherited a jar that contains a few domain classes and a spring context that creates a session factory for Hibernate. This is a redacted version of the context file's hibernate pieces:



<tx:annotation-driven transaction-manager="transactionManager" />

<bean id="dataSource" class="com.ours.OurDataSource">
<constructor-arg value="dml-rdbms-data-source.properties" />
</bean>

<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="searchSessionFactory" />
</bean>

<!-- Hibernate SessionFactory -->
<bean id="searchSessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource">
<ref local="dataSource" />
</property>
<property name="annotatedClasses">
<list>
<value>a.b.c.DefGhe</value>
<value>a.b.c.Xyz</value>
</list>
</property>
<property name="hibernateProperties">
<bean class="our.com.ManagedPropertiesFactory" factory-method="getProperties">
<constructor-arg value="hibernate.properties" />
</bean>
</property>
</bean>


I changed the sessionFactory bean to be called searchSessionFactory in order to avoid a name collision with the built-in grails hibernate session factory. That doesn't seem to help. I still get this error when trying to save a Grails-generated domain class:



Unknown entity: x.y.z.DomClass; nested exception is org.hibernate.MappingException: Unknown entity: x.y.z.DomClass


Has anyone run into a situation where they had to integrate existing hibernate functionality like this into Grails?


Aucun commentaire:

Enregistrer un commentaire