myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rene Guenther <>
Subject Hibernate ManyToOne and JSF SelectMenu
Date Fri, 14 Dec 2007 15:42:08 GMT

I got an manyToOne mapping from User to Cost Center.
On my userForm.jsf I got sth like

<t:selectOneMenu value="#{}" id="cc" required="true"
styleClass="select" />
       <f:selectItems value="#{ccManager.objects}" />

userForm.user.getCcenter() is "under control" of hibernate. If I select a
new cost center this results in a change of the value of
userForm.user.getCcenter().getId(). Before saving the user I have to
retrieve the new cost center object from the database. Until now everything

Lets say I got for some reason another user object in my session. This user2
is assigned to the same cost center, this results to user.getCcenter() ==
user2.getCcenter(); not just equals. Now I might come into trouble if I
change the id of the cost center of user by selecting a new one with
selectOneMenu, because user2.getCcenter().getId() will be changed too of

You know whether there is a recommended way how to use manyToOne mapping
together with a selectMenu?


View this message in context:
Sent from the MyFaces - Users mailing list archive at

View raw message