0
votes

I have a Grails application using some proprietary NoSQL DB. I have the hibernate plugin disabled. I have many domain classes with lots of constrains defined and with own implementation of save() and get() that calls some java services that are dealing with persistence. Everything is working fine.

But now, we have a deal with a client to save some things directly into their MySQL DB. Simple thing at first. I configured their DB connection, enabled hibernate plugin and I created a new domain class to deal with that. Everything is working fine in a test app, but when i enabled the hibernate plugin into main project, is not starting anymore.

Hibernate is trying to map all domains to tables in the DB and of course they do not exists (because are using the NoSQL DB).

My questions is: Can I enable hibernate just for several domains? Or can I instruct some domain to not use hibernate/gorm? Or per package? How is Grails handling multiple DBs for same project?

2

2 Answers

2
votes

You can set multiple datasources to take care of NoSQL db and MySQL db. Then you will be left with the domain objects which uses Java services for persistence.

You are using constraints on them but are you leveraging the Gorm Static API like dynamic finders on them? To abstract them from hibernate implementation, I would try moving them from grails-app/domain to src/groovy or use static mapWith = 'none' in classes.

1
votes

You can configure this with the mapWith option in the domain class.

Related SO question: Is it possible in grails to disable persistence of a domain class?