-->
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.  [ 8 posts ] 
Author Message
 Post subject: MultiLevel Users Apllication architeture/model question
PostPosted: Mon Apr 26, 2004 9:27 am 
Newbie

Joined: Fri Mar 26, 2004 7:02 am
Posts: 17
I've posted my question into the worng forum so i repost the link here:

http://forum.hibernate.org/viewtopic.php?t=930299


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 26, 2004 9:33 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
ok so lets talk here
give relationnal model please


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 26, 2004 9:56 am 
Newbie

Joined: Fri Mar 26, 2004 7:02 am
Posts: 17
CREATE TABLE ph_diadoracommunity_users (
u_id int(10) unsigned NOT NULL default '0',
name varchar(10) ,
email varchar(10) ,
PRIMARY KEY (u_id),
KEY u_id (u_id)
) TYPE=MyISAM;


CREATE TABLE ph_diadoracommunity_users_lv1 (
u_id int(10) unsigned default '0',
address varchar(30) default '0',
KEY u_id (u_id)
) TYPE=MyISAM;



CREATE TABLE ph_diadoracommunity_users_lv2 (
u_id int(10) unsigned NOT NULL default '0',
code varchar(10) default '0',
PRIMARY KEY (u_id),
KEY u_id (u_id)
) TYPE=MyISAM;

The mapping:
<hibernate-mapping>
<class name="ph.news.model.UtenteBase" table="ph_diadoracommunity_users" >
<id name="id" type="int" column="u_id" unsaved-value="0">
<generator class="identity"/>
</id>


<property name="name"/>

<property name="email"/>

<joined-subclass name="ph.news.model.UtenteLivello1" table="ph_diadoracommunity_users_lv1">
<key column="u_id"/>
<property name="address"/>

<joined-subclass name="ph.news.model.UtenteLivello2" table="ph_diadoracommunity_users_lv2">
<key column="u_id"/>
<property name="code"/>
</joined-subclass>
</joined-subclass>

</class>

</hibernate-mapping>

I don't know if this is the right way to model this situation (I think NO) but note that a ph.news.model.UtenteLivello1 (UserLevel1) MUST BE ALSO a ph.news.model.UtenteBase (BaseUser)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 26, 2004 10:25 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
what tests have you done with this solution? it seems ok for me


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 26, 2004 10:32 am 
Newbie

Joined: Fri Mar 26, 2004 7:02 am
Posts: 17
I' ve a Level1User Object with its email, name and its Id: 1.

Now The user id=1 fill a Level 2 registration form, he fills the code than post data, my app should get the UserLevel1 with id=1 and "transform" it in a user of level1 BUT with the same Id. I' can't do it ...

UtenteLivello1 ub=(UtenteLivello1) sess.load(UtenteLivello1.class,new Integer(1));

UtenteLivello2 u2=new UtenteLivello2(ub); //Copy the state

sess.save(u2,new Integer(1));
sess.flush();


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 26, 2004 10:47 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
stacktrace?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 26, 2004 10:51 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Delete the old object first, I'd say. Besides, Inheritance is not particulary good to model such "type changing" behaviour, consider using aggregation.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 26, 2004 11:00 am 
Newbie

Joined: Fri Mar 26, 2004 7:02 am
Posts: 17
ok, I uderstand: I can't delete because I've reltionships with other entities with cascade="delete" attribute.... I'll try to change my design with aggregation!

THX


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