Quick newbie question: I am using middlegen to create my [pojo]hbm.xml files which are then used to create pojos. This works great. The objects go in and out of hibernate like a charm. I'm trying to see how well full blown round trip development will work in a database driven context.
Here is the catch: I would like to apply the generation gap pattern to those generated pojos. (this is not meant to raise a discussion about the sensibility of this strategy :-))
Here is an issue: when the pojos that are generated are subclassed, those subclasses cannot be persisted: hibernate cannot find a persister since hibernate does not know that the subclass is supposed to be persistent. This makes sense - the subclass of the pojo is not declared by the name attr of the class element in the [pojo].hbm.xml file. Rather, the generated class is. Unfortunately that keeps the generation gap subclass from being used during runtime.
Solutions as I see them:
1) Have middlegen assume that a pojo subclass (the generation gap pattern) will exist and write out the [pojo].hbm.xml in an manner that anticipates a known subclass will exist. This is problematic for those generated pojos that are not subclassed.
2) Have a post processing step that tweaks the [pojo].hbm.xml with the generation gap subclass name right after compilation but before runtime. This works. Doesn't seem ideal.
3) Change my pojo.vm template in a way allowing the hbm2java velocityrenderer to generate the pojo in a way leaving the hbm.xml's accurate when a subclass is made.
So what is my question? How can a subclass be persisted in hibernate without having to define it in an [pojo].hbm.xml file? Maybe someone will tell me to RTFM since I'm guessing there is some runtime registration technique. Hopefully.
Thanks,
Rich
|