Association between legacy mapping and gorm mapped class

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
Report Content as Inappropriate

Association between legacy mapping and gorm mapped class


I remember someone asking this question sometime earlier.

I'm wondering if the following is possible using GORM.  I have a collection of legacy java domain objects and hibernate mapping files that I access from a jar in the lib directory.  These are mapped using a hibernate.cfg.xml file in the conf/hibernate directory.  These are fully accessible when using the GORM dynamic methods when my app is running.  My problem appears when I try to make a unidirectional association from a  newly created groovy domain class to one of the classes contained within the legacy jar.

For example,

The files in the jar file are

In the new groovy domain class
import org.legacydomain.Foo

Class bar {

    Foo myfoo

This throws a null pointer exception during start-up of the application which
seems to occur here (pulled from the full stacktrace.log file)

Caused by: java.lang.NullPointerException
        at org.codehaus.groovy.grails.commons.DefaultGrailsDomainClassProperty.equals(
        at org.codehaus.groovy.grails.commons.GrailsDomainConfigurationUtil.configureDomainClassRelationships(
        at org.codehaus.groovy.grails.commons.DomainClassArtefactHandler.initialize(
        at org.codehaus.groovy.grails.commons.DefaultGrailsApplication.initializeArtefacts(
        at org.codehaus.groovy.grails.commons.DefaultGrailsApplication.initializeArtefacts(
        at org.codehaus.groovy.grails.commons.DefaultGrailsApplication.addArtefact(
        at org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsHibernateUtil.configureDomainClass(
        at org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsHibernateUtil.configureHibernateDomainClasses(
        at org.codehaus.groovy.grails.orm.hibernate.ConfigurableLocalSessionFactoryBean.newSessionFactory(
        at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(
        at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(

Does anyone have any suggestions as to why this would be the case?  Similarly
is it even possible to make this kind of association?

Thanks for any help anyone can provide,

It would be great if someone can throw some light on what is happening in that part of the code which is causing the issue.

460  GrailsDomainClassProperty otherProp = (GrailsDomainClassProperty) o;
461  boolean namesMatch = otherProp.getName().equals(getName());
462  boolean typesMatch = otherProp.getReferencedPropertyType().equals(getReferencedPropertyType());
463  Class myActualClass = getDomainClass().getClazz();
464  Class otherActualClass = otherProp.getDomainClass().getClazz() ;
465  boolean classMatch = otherActualClass.isAssignableFro