-->
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: Dynamic Tables with Hibernate
PostPosted: Wed Apr 07, 2010 4:30 am 
Newbie

Joined: Wed Apr 07, 2010 4:14 am
Posts: 3
hello guys,
i´m a newbie to hibernate so please be gentle. i want to write a user administration for a school, where the data is stored in a postgresql database.
persons are assigned to groups, that is the only thing necessary to explain for my specific problem.
now this wouldn´t be much of a problem, but one requirement is to import groups to groups. so i.e 4 person from group A can be put as a group in group B and so on.
now to reslove the members of a group who might be in many groups before i had a scheme like this.
table person:
-id
-firstname
-surname
-.......

table groups:
-id
-nameofgroup
-.......

and now there is(for me) difficult part: the table group, which is created dynamically to store the members, which can be persons or groups.
so everytime i create a new group, i have to dynamically create a table i.e with a prefix [grp]_grpname. the scheme stays the same only the name changes according to the group.
table group:
-id
-fid(id of person or group)
-type(person/group, where to look)

now is it possible to make a dynamic model using hibernate or what do you suggest?

p.s.: please excuse my english, i´m a german fellow.

Kind Regards

Hyyuga


Top
 Profile  
 
 Post subject: Re: Dynamic Tables with Hibernate
PostPosted: Wed Apr 07, 2010 4:46 am 
Regular
Regular

Joined: Wed Mar 10, 2010 4:48 am
Posts: 106
I would make 2 extra tables: groupPersons and groupGroups.


Top
 Profile  
 
 Post subject: Re: Dynamic Tables with Hibernate
PostPosted: Wed Apr 07, 2010 5:18 am 
Newbie

Joined: Wed Apr 07, 2010 4:14 am
Posts: 3
aukemid wrote:
I would make 2 extra tables: groupPersons and groupGroups.

dont get the point. would you please explain this.


Top
 Profile  
 
 Post subject: Re: Dynamic Tables with Hibernate
PostPosted: Wed Apr 07, 2010 6:09 am 
Regular
Regular

Joined: Wed Mar 10, 2010 4:48 am
Posts: 106
If you make 4 objects:
Person => contains the data about the person: name, age
Group => contains the data about the group: name

GroupPerson => contains a FK to Group and a FK to Person (and perhaps other data)
GroupGroup => contains two different FK's both to Group (and perhaps other data)

This way all data is in the Person or Group object.
And the relations are in GroupPerson and GroupGroup.

You can store persons in groups and groups in groups.


Top
 Profile  
 
 Post subject: Re: Dynamic Tables with Hibernate
PostPosted: Wed Apr 07, 2010 7:18 am 
Newbie

Joined: Wed Apr 07, 2010 4:14 am
Posts: 3
aukemid wrote:
If you make 4 objects:
Person => contains the data about the person: name, age
Group => contains the data about the group: name

GroupPerson => contains a FK to Group and a FK to Person (and perhaps other data)
GroupGroup => contains two different FK's both to Group (and perhaps other data)

This way all data is in the Person or Group object.
And the relations are in GroupPerson and GroupGroup.

You can store persons in groups and groups in groups.


ah ok i see, this way i dont need to create tables dynamically.

thanks for your reply.

anyone else got an opinion on this?


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.