-->
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.  [ 7 posts ] 
Author Message
 Post subject: mapping the same class to several tables
PostPosted: Sun Oct 24, 2004 11:42 am 
Newbie

Joined: Mon Oct 18, 2004 10:59 am
Posts: 4
Hi,

I'm planning an application and am evaluating Hibernate because I'm thinking about possibly using ot for that. My application provides an abstract access to a database (read-only). It's supposed to be able to read data from any tables and return an object with an array property containing the values (like "name" => "dsds", "date" => Date Object etc). That means I want to be able to map any tables to always the same object (of course I don't want to create the classes to map with a one-class-per-table approach everytime I configure a new table). I hope the explanation was understandable.
Does anybody know if or how I could do that using Hibernate? I think it would provide me with a lot of functionality. Would it be maybe sufficient if I would just write my own Loader or Persister class?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 24, 2004 11:50 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Looks like <dynamic-class> in Hibernate3 is what you need.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 24, 2004 2:38 pm 
Newbie

Joined: Mon Oct 18, 2004 10:59 am
Posts: 4
is there any documentation for that?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 24, 2004 3:02 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
No :) Works the same as <class>, but you get a Map of property-name, value tuples


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 25, 2004 7:31 am 
Newbie

Joined: Mon Oct 18, 2004 10:59 am
Posts: 4
alright, I'll try to find out myself. Is Hibernate3 ready for use or is it really alpha? I know there's no a stable release but perhaps everything I need (I don't need any writing to the DB etc.) is including and running already?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 25, 2004 7:43 am 
Newbie

Joined: Mon Oct 18, 2004 10:59 am
Posts: 4
I just recognized another possiblity to solve my problem. wouldn't it be possible to generate the class files for the tables i want to read from the db using hbm2java? as far as i understand it that would create the class files with get and set methods so that hibernate would create instances of the classes according to the data in the table. the only thing i would have to do is to add a method for each class that returns all properties as a set of key/value pairs.
is that correct? would that work or am i wrong?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 25, 2004 9:26 pm 
Regular
Regular

Joined: Sat Aug 28, 2004 4:15 pm
Posts: 61
hbm2java simply produces Classes NOT instances.

The tool doesnt generate .class files. It generates .java files and those files are based off of the Hibernate Mapping files - not the database, as you can gather from its name - hbm2java.

Anyway, hope that helps.

_________________
Joe W


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