-->
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: extends classes of hibernate
PostPosted: Tue Mar 02, 2004 12:36 pm 
Beginner
Beginner

Joined: Mon Sep 15, 2003 9:10 am
Posts: 43
I have a schema :

<class name="framework.modele.DBUser" table="users">
<id name="id" type="int" unsaved-value="0" >
<column name="id" sql-type="int" not-null="true"/>
<generator class="native" />
</id>
....
</class>



Than produce this file : (mapping objet)

/** @author Hibernate CodeGenerator */
public class DBUser implements Serializable {
....
}



I create this file: (entreprise object)

public class Utilisateur extends DBUser {


}

Is it a good way ?

Can i use the entreprise object in my form-bean of struts ? I don't want to write all the properties ... another time...

Is there another way ?


Thanks for your answer ! I'm ready to discuss about this.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 02, 2004 1:22 pm 
Regular
Regular

Joined: Mon Nov 24, 2003 6:36 pm
Posts: 105
I think this is not a good idea. You can find lot's of folks talking about application architecture in the other forum, however, so this is my 2cents.

I always have actionforms that are different than their Domain Model/Object model counterparts for the following reasons:

1. If you want to "remember" what a user types in to a form, (when a validation error occurs), you want to show the user exactly what the user typed, not what BeanUtils will convert it to.

2. What you want to do only makes sense when you have very simple screens that map 1:1 with the DB. Frequently the UI that is required does not easily map 1:1 with the db.

3. Check out some of Ted Husted's posts on why an action form is not an interface


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 02, 2004 1:31 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
jlawmi
have seen it?
http://forum.hibernate.org/viewtopic.php?t=928244



what are you using?


Top
 Profile  
 
 Post subject: so ... ?
PostPosted: Tue Mar 02, 2004 2:11 pm 
Beginner
Beginner

Joined: Mon Sep 15, 2003 9:10 am
Posts: 43
so if i understand :

- i create a form bean with all properies
- i create a BOUser with the logic business
- i create a DBUser (java mapping from my schema) for db

form bean :

class formUser{
String name;
int idProfil;
..
}


class BOUser{
String name;
int idProfil;

void save(){

DBUser dbUSer=new ...();
beanUtil.copyproperties(dbUser,boUser);

session.save(dbUser);
}

void delete();
void update();
}

class DBUser{
String name;
DBProfil profil;

...hibernate part :

setDBProfil(DBProfil)...
getDBProfil(DBProfil)...

}


So in the application :
1. tranfert what users type in the form in formbean (made by struts)
2. In the action : use a beantutil to tranfert data from beanform to a new BOUser instance boUser.
3. Call boUser.save();

with the method :


It work fine except for my profil ? Is it a good way ?

Please help...


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.