|
Hi,
Our Domain Model implements via hibernate mapping and Java classes. Some Domain Classes are placed in inline plugins and have own registration with the Hibernate SessionFactory e.g.: <plugins>/grails-app/conf/hibernate/hibernate.cfg.xml But we can not do this registration for multiple plugins. In fact only mappings from the first plugin are registered! Yes, it's possible, to register all mappings directly in application, but we don't know which mapping are provided by plugins. Finally, we want to get plugins, that use hibernate mappings without additional external configuration in application. We know that it's working for GORM. Grails looking for GORM Objects in all plugins and initialize them properly. But how to deal with Model based on the hibernate mapping? Does anybody faced with this issue? Any ideas, feedback are welcome. Thank you. |
|
I do something like this (i.e., using multiple Hibernate mapping
files), but I am using the Datasources plugin. For each additional datasource provided by an inline plugin, say, ''ds2', I have a config file ds2_hibernate.cfg.xml stored in the plugin's conf/hibernate/package-name This is picked up auto0magically by the datasouces plugin. Not sure that info is helpful, but ... -- Jonathan Rosenberg Founder & Executive Director Tabby's Place, a Cat Sanctuary http://www.tabbysplace.org/ On Tue, Apr 10, 2012 at 8:19 AM, Ivan Staskov <[hidden email]> wrote: > Hi, > > Our Domain Model implements via hibernate mapping and Java classes. > Some Domain Classes are placed in inline plugins and have own registration > with the Hibernate SessionFactory > e.g.: > <plugins>/grails-app/conf/hibernate/hibernate.cfg.xml > > But we can not do this registration for multiple plugins. In fact only > mappings from the first plugin are registered! > > Yes, it's possible, to register all mappings directly in application, but we > don't know which mapping are provided by plugins. > > Finally, we want to get plugins, that use hibernate mappings without > additional external configuration in application. > We know that it's working for GORM. Grails looking for GORM Objects in all > plugins and initialize them properly. > > But how to deal with Model based on the hibernate mapping? > Does anybody faced with this issue? > > Any ideas, feedback are welcome. > > Thank you. > > -- > View this message in context: http://grails.1312388.n4.nabble.com/Multiple-registration-of-hibernate-mappings-in-plugins-tp4545427p4545427.html > Sent from the Grails - user mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
Thanks a lot for the quick reply,
But in your solution we will have separate SessionFactory for each group of hibernate mappings (in our case for each plugin). It means that for usage Domain from this plugin we should explicit define datasource: DomainClass.ds2.list() Because 'DomainClass' has been mapped in 'ds2' data source only... In any case, thanks for idea! |
|
Are all of your domains sharing the sdame datasource?
-- Jonathan Rosenberg Founder & Executive Director Tabby's Place, a Cat Sanctuary http://www.tabbysplace.org/ -- Jonathan Rosenberg Founder & Executive Director Tabby's Place, a Cat Sanctuary http://www.tabbysplace.org/ On Tue, Apr 10, 2012 at 10:22 AM, Ivan Staskov <[hidden email]> wrote: > Thanks a lot for the quick reply, > > But in your solution we will have separate SessionFactory for each group of > hibernate mappings (in our case for each plugin). > It means that for usage Domain from this plugin we should explicit define > datasource: > > DomainClass.ds2.list() > > Because 'DomainClass' has been mapped in 'ds2' data source only... > > In any case, thanks for idea! > > > -- > View this message in context: http://grails.1312388.n4.nabble.com/Multiple-registration-of-hibernate-mappings-in-plugins-tp4545427p4545768.html > Sent from the Grails - user mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
Yes, all Domain Objects (about 100 entities) use one data source.
Now we faced with necessity to split Model on separate modules with independent functionality. |
|
Have you tried overriding the sessionFactory bean in resources.groovy with ConfigurableLocalBean (or whatever its called) & specifying your own config files, using configLocations, I believe? On Apr 10, 2012 12:41 PM, "Ivan Staskov" <[hidden email]> wrote:
Yes, all Domain Objects (about 100 entities) use one data source. |
|
We found ability to implement this.
Bean "abstractSessionFactoryBeanConfig$suffix" that registered in HibernatePluginSupport.groovy has configuration for hibernate configuration location ... def explicitLocations = hibConfig?.config?.location if (explicitLocations) { if (explicitLocations instanceof Collection) { hibConfigLocations.addAll(explicitLocations.collect { it.toString() }) } else { hibConfigLocations << hibConfig.config.location.toString() } } ... It receives the collection of paths to hibernate mapping files (cfg.xml) from grails-app/conf/DataSource.groovy: hibernate { config.location = "file:hibernate.cfg.xml" } Thus we can inject here a Provider which will looking for "*.cfg.xml" inside plugins and returns paths to them (override 'collect' method which will return collection of paths, found by this Provider). Unfortunately, this is not Grails 'native' approach and need additional effort for implementation and support some 'convention' for names of *.cfg.xml file inside Plugins. In any case, thanks a lot for feedbacks. |
|
This is the class I was thinking of:
http://grails.org/doc/latest/api/org/codehaus/groovy/grails/orm/hibernate/ConfigurableLocalSessionFactoryBean.html -- Jonathan Rosenberg Founder & Executive Director Tabby's Place, a Cat Sanctuary http://www.tabbysplace.org/ On Wed, Apr 11, 2012 at 9:14 AM, Ivan Staskov <[hidden email]> wrote: > We found ability to implement this. > Bean "abstractSessionFactoryBeanConfig$suffix" that registered in > HibernatePluginSupport.groovy has configuration for hibernate configuration > location > ... > def explicitLocations = hibConfig?.config?.location > if (explicitLocations) { > if (explicitLocations instanceof Collection) { > hibConfigLocations.addAll(explicitLocations.collect > { it.toString() }) > } > else { > hibConfigLocations << > hibConfig.config.location.toString() > } > } > ... > > It receives the collection of paths to hibernate mapping files (cfg.xml) > from grails-app/conf/DataSource.groovy: > hibernate { > config.location = "file:hibernate.cfg.xml" > } > > Thus we can inject here a Provider which will looking for "*.cfg.xml" inside > plugins and returns paths to them (override 'collect' method which will > return collection of paths, found by this Provider). > > Unfortunately, this is not Grails 'native' approach and need additional > effort for implementation and support some 'convention' for names of > *.cfg.xml file inside Plugins. > > In any case, thanks a lot for feedbacks. > > > -- > View this message in context: http://grails.1312388.n4.nabble.com/Multiple-registration-of-hibernate-mappings-in-plugins-tp4545427p4548846.html > Sent from the Grails - user mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
Yes, it can be used too.
Thank you. |
| Powered by Nabble | Edit this page |
