-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: generation gap pattern with middlegen
PostPosted: Sat Nov 06, 2004 12:18 am 
Newbie

Joined: Fri Nov 05, 2004 11:45 pm
Posts: 1
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


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 06, 2004 7:26 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
hbm2java has support for heirachry creation to allow business methods to be added so the main class can be regenerated without any code being clobbered issues. There are examples if you search the forum.

If this is not what your looking for please provide a small example of what you want so there is no miss-interpretation on my part.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.