-->
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: Persisting 3rd party POJO's (or introducing dynamic fields)
PostPosted: Tue Mar 01, 2005 11:50 am 
Newbie

Joined: Tue Mar 01, 2005 11:39 am
Posts: 8
Hibernate version: 2.1.8

I have a POJO (plain old java object) that comes from a 3rd party SDK that I would like to persist using hibernate. I have created a hibernate mapping file for it and I am able to save it to the database without a problem.

Now I am finding that I would like to introduce a few fields such as a hibernated generated id (currently I am using assigned keys due to the 3rd party SDK populating the object with a unique ID) as well as createdOnDate and modifiedOnDate but since I can not change the underlying class (managed by a 3rd party) I am not sure what my options are beyond subclassing the 3rd party class and adding the fields then creating a mapping for that object. I would rather not do this as I would have to subclass quite a few classes.

Does hibernate support injecting dynamic fields such as ID that don't exist on the underling class? My guess is if it does it would be quite hackish but if someone has a solution it would be appreciated.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 01, 2005 12:44 pm 
Regular
Regular

Joined: Thu Dec 18, 2003 2:14 am
Posts: 103
Location: Brooklyn, NY
I don't see a way around subclassing, but you could use some tools or scripts to automate this for you.
How many classes are you talking about? Unless its hundreds, you just need to add 6 methods in your subclasses.


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.