-->
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.  [ 4 posts ] 
Author Message
 Post subject: can i accomplish this with hibernate?
PostPosted: Wed Jan 26, 2005 1:42 pm 
Newbie

Joined: Wed Jan 26, 2005 1:28 pm
Posts: 5
Hello All,

This a sort of a 'pre-sales' question. I am not using hibernate yet but am certainly considering it.

My Postgres db schema set-up is quite unique: for example, instead of having one table for user object i have 2 tables:

tb_user {
uid pk
app_id
name
email
}

tb_user_property {
uprop_id pk
uid fk
prop_name
prop_value
}

so, basically user will have just the most essential metadata for the user and the rest of user data is stored as properties (this is to enable using teh same db schema by multiple applications i am developing).


then i have a java object (User) which looks similar to this:

public class User {
int uid
int appid
String name
String email
List properties
}

now the question is: will i be able to utilize hibernate to perform CRUD operations on such db structure? (i. e. my finders should be able to collect user data from the two tables joined; the create should store data in the two tables, etc.). will the solution be elegant or more of a hack? Any pointers to some relevant reading material?

If my question is not entirely clear, please ask for clarification. I really appreciate your help.

James


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 26, 2005 2:01 pm 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
I think that you have standard one to many realtion and it owkr perfect with hibernate

regards


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 26, 2005 2:04 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
That is hardly a unique schema design ;)

Yes Hibernate can handle what you describe. It's a simple fk association.

This can be mapped as either a list of entities or as a list of components (see the docs for meanings if you don't understand). In fact Hibernate will even let you do things like map the User.properties property as a Map of key/values... All kinds of options :)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 26, 2005 2:45 pm 
Newbie

Joined: Wed Jan 26, 2005 1:28 pm
Posts: 5
Thanks a lot for your help, all! I'll get started with the manual then

James


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