-->
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.  [ 5 posts ] 
Author Message
 Post subject: Generating Pojo class and mapping on the fly
PostPosted: Thu Jun 28, 2007 1:57 pm 
Newbie

Joined: Thu Jun 28, 2007 1:46 pm
Posts: 7
I would like to generate POJO classes and the mapping file on the fly (in the runtime). Would you please give me sample source code to do this with

Hibernate version: 3.2

Hibernate Tools version: 3.2

Databaseversion: MySQL 5.x


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 29, 2007 3:19 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
I don't understand what you are asking for ?

How are you going to write code for thse classes and mappings if you don't have them at compile time ? ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 29, 2007 3:13 pm 
Newbie

Joined: Thu Jun 28, 2007 1:46 pm
Posts: 7
I got the DataModel in the Database Schema already. Following is my approach (at runtime):
Schema -> Mapping Files (.hbm.xml) -> Pojo classes (.java)

Because the Pojo classes simply contain get/set method, I can invoke those methods at the runtime using Reflection API.

The purpose of following this approach is that at compile time I dont have to care about the entity, how it saved and loaded, because the entity is created at the runtime.

The entities and its relation are created at the run time and we design the database schema for it, then update DB. Then we start the program without changing any code because of the automated approach above. That's the whole idea about this.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 02, 2007 4:24 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
so invoke reverse engineering, call hbm2java and compile the classes......

Nothing special, but also nothing that I would ever recommend doing if you want a performant system.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 03, 2007 5:11 pm 
Newbie

Joined: Fri Feb 23, 2007 4:37 pm
Posts: 4
You can look into dynamic mapping of hibernate. But you can't do everything on the fly. You have to restart to got new fields/classes into the system.

_________________
Tim


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