Reputation: 32056
In a Grails project, if I place my entity classes in the /domain folder, Grails automatically attempts to use GORM/Hibernate for persistence. If I'm peristing to a different type of store, say Mongo, Reddis, etc, can I still place my classes in the domain folder and implement my own persistence logic?
I've disabled hibernate
and domain
in BuildConfig.groovy
using excludes 'hibernate,domain'
, but Grails still complains..perhaps I should just place my domain classes in src/groovy/mypackage
...
Upvotes: 4
Views: 2095
Reputation: 75671
Grails slightly misuses the term domain. Domain classes in Grails are persistent classes, whether they're persistent with Hibernate or NoSQL or both. If you want to manage things yourself put them in src/groovy.
If you want to use NoSQL consider using one of the plugins, e.g. mongodb or redis-gorm. If the NoSQL plugin is the only persistence plugin installed (i.e. you've removed the Hibernate plugin) then a domain class in grails-app/domain will use that plugin. If you still have the Hibernate plugin installed, the domain class will default to being a Hibernate domain class but you can specify that it's a NoSQL domain class with the mapWith
property, e.g. static mapWith = "mongo"
. This is described in the docs for the plugins.
You probably don't want to remove the domain plugin though - I don't think there's any benefit and it'll most likely break important features.
Upvotes: 4