Hi!
I am using hibernate for quite sometime now and has been a happy user.
Recently my project required a solution where runtime inheritance and its persistance was required (so I thought) and its difficult to solve in hibernate.
Let me tell you about the problem....
I have an accounting system which has Object model as follows
AccountBook (Contains multiple account groups)
AccountGroup (Can contain multiple Account Sub groups or Account Heads)
AccountHead (Can contain multiple Account Entries)
AccountEntry
To model this object graph bidirectionally is not difficult in hibernate until you know this that AccountEntries can be of different types and will be configured by users at runtime. For eg, I as an user can configure AccountEntry types to be anything depending on my organizations requirement. For eg, I can choose ...
1) GeneralLedger
2) AccountsReceivable
3) AccountsPayables
4) ProfitLossAccount
Typically, user will name the AccountEntry type on a webpage and will define the fields each type of AccountEntry will contain.
To model this requirement, I needed to create a subclass for AccountEntry dynamically (GeneralLedger extends AccountEntry, for eg) with all the fields as specified by the user at runtime and then I have to compile dynamic class as well at runtime and then have to create mapping files, update hibernate configuration and rebuild the factory.
I am successful to do all that dynamically but its very tedious and does not work on JBoss because when I load dynamically created class (which I generate in an external folder than Jboss) which extends from AccountEntry, the classloader upperdelegation model fails to load dynamically generated class though it can find it because it extends from AccountEntry which resides within WAR file and hence scoped and cannot be accessed by classloader which loads GeneralLedger dynamic class which is not scoped.
can somebody suggest a different way to model the above problem or suggest a workaround so that works on JBoss
Rgds
|