I'm developing a Grails application that will access a large legacy database (that will continue to be used by other legacy software). I've created various groovy classes to mimic domain models for the legacy database (because they pull data from multiple tables they can't be actual grails domain model classes since grails/hibernate can only do one table per class).
I'm now working on new parts of the application that will add new tables to the database, so for these I can use actual grails domain model classes and have grails/hibernate do its thing. The problem I'm running into is that my actual grails domain model classes need to have some of the pretend domain model classes as their properties. However, hibernate fails on this since it doesn't know how to deal with these pretend domain model classes.
I'm looking for suggestions on how to deal with this situation from a design point of view. One way that I can think of is to not actually have the pretend domain model class be a property of the grails domain model class, but instead store some sort of unique identifier that can identify/recreate the pretend domain model class. However, I'm hoping for a more elegant solution to this or if there isn't one, then a way to automate this, so that it's as seemless as possible.
Any suggestions, idea, etc. are much appreciated.
I ended up using custom hibernate types to solve my problem (http://grails.org/doc/2.3.x/guide/GORM.html#customHibernateTypes). They allow me to automate the process of storing some sort of identifier(s) in the domain model class to recreate/reload the pretend domain model class.