Sharing a grails app domain plugin among multiple grails application clients and sing subset of domain classes
Well this is a strange requirement and I'm thinking about it if this is possible or not. Second thou开发者_JAVA技巧ght comes is whether if its a feasible design decision or not.
Here is the scenario:
We have a database composed of some 160 tables. We created a Grails ORM plugin on top of the legacy database.
Now we have different applications (plugins) who will use this orm plugin.
Each application can run standalone and combined with other applications as well.
Every application mainly use a subset of complete ORM model designed in the plugin.
In order to run an app standalone, I only want to create a standalone database that contains tables required by the application and not the whole database of 160 tables. But as standalone application has a dependency on the ORM plugin defined above, is that possible or not to have just a subset of tables or I've to create full database schema?
Let me know if any further details are required to understand the question.
Thanks, Alam Sher
You could declare the ORM-mapped domain classes in src/groovy
folder and thus not map anything in the plugin, and then extend the necessary classes in end applications. Mappings declared in src
will be used.
This adds extra complexity, but does the thing.
I'd suggest splitting up the ORM plugin into seperate "sub-orm" plugins. These "sub-orm" plugins might depend to other "sub-orm" plugins of course. The dividing lines between the "sub-orm" plugins should IMHO be defined by the business domain.
Each "partial" application might then have a dependency to the required "sub-orm" plugins that are just necessary within its scope. Transitive dependency resolution is valuable in this case.
In general be aware if multiple different applications access the same database concurrently, there's a risk of getting locking exceptions from Hibernate.
精彩评论