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.  [ 11 posts ] 
Author Message
 Post subject: Runtime model mapping
PostPosted: Thu Dec 01, 2005 2:21 pm 
Newbie

Joined: Wed Nov 30, 2005 9:39 pm
Posts: 10
Hi

I'm using Hibernate3, and am trying to create model mapping at runtime.
What I mean by that is, I don't want to use the XML based mapping, nor do I want to use annotations (I'm using JDK 1.4.2). I want to generate the actual Mapping myself. Now, I know I should createMappings(), then add a bunch of RootClass/SubClass definitions, then do a secondpass for the relationships - that's all good in theory. In practice, I encounter many problems, and all sorts of weird exceptions. Does anyone know of a good working code example for this method of mapping?


thanks
Gadi


Top
 Profile  
 
 Post subject: That's nice, but...
PostPosted: Thu Dec 01, 2005 2:48 pm 
Contributor
Contributor

Joined: Thu Nov 06, 2003 9:49 pm
Posts: 104
Location: New York, NY
Well, you can do that but I don't see the point if you are not also generating the Java classes for the mapped objects at runtime as well.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 01, 2005 3:40 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
HBMBinder, JDBCBinder and AnnotationBinder is all doing this...so go look there ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 01, 2005 3:54 pm 
Newbie

Joined: Wed Nov 30, 2005 9:39 pm
Posts: 10
Hi Max

Thanks, these are a good reference. I would like to know, however, if there is a better documentation (preferably by an example) of the mapping process. I really only want to do some basic mapping (at least at first) - while those Binders are very generic. What is the minimal set of steps I need to go through in order to map a simple class (like Person or Cat...).

thanks
Gadi


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 01, 2005 3:56 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
look at JDBCBinder - that is the most minimal example.

Look at createPersistentClasses which does what is needed.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Re: That's nice, but..
PostPosted: Thu Dec 01, 2005 4:00 pm 
Newbie

Joined: Wed Nov 30, 2005 9:39 pm
Posts: 10
Hi Joshua

The use case is as follows: we have a very large number of objects to persist, and having to keep a mapping documents repository has some issues with it:
1. We already have the classes in place, and it will be a lot of repetitive labor work to create trivial mappings.
2. We will then need to keep the mapping documents in sync with class changes.
3. Other applications running on top of ours (it's a framework) can actually add their own persistent classes - I wouldn't want them to be aware of the persistent layer implementation (Hibernate), so I don't want to enforce them to supply XML mapping documents.
4. The mapping, in most cases, is very simple (the classes are a part of an information model, so there are clear guidelines to how they should be written, they all return basic types, etc.) - so the mapping is really straightforward in almost all cases. For the non-trivial we'll use XML mapping.

hope that explains the motivation
Gadi


Top
 Profile  
 
 Post subject: JDBCBinder
PostPosted: Thu Dec 01, 2005 4:04 pm 
Newbie

Joined: Wed Nov 30, 2005 9:39 pm
Posts: 10
When was JDBCBinder introduced (the sources I'm looking at are 3.0.1, was this added later?)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 01, 2005 4:10 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
JDBBinder is in hibernatetools..


btw. if the mappings are so simply why not generate a in-memory xml representation and let hbmbinder parse it ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 01, 2005 4:48 pm 
Newbie

Joined: Wed Nov 30, 2005 9:39 pm
Posts: 10
This was one of the approaches we thought about, just thought we might be able to easily get rid of the overhead of generating a Document each time (we have several hundreds classes in the information model..)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 01, 2005 4:53 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
get rid of the overhead ?

serialize the xml document to disk - that will give you almost no overhead.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 01, 2005 10:52 pm 
Newbie

Joined: Wed Nov 30, 2005 9:39 pm
Posts: 10
yes, that's what we'll probably do, thanks...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 11 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.