I think you are trying to enter the ID of an Employee record and have that id become the Employee object when the User is processed by Struts. What you have now is Struts will create a blank Employee object and call user.setEmployee() and then will set the id property of that Employee, employee.setId(). I am not sure about your @JoinColumn annotation, I would have to look it up to see if there is something there that could be messing things up. I usually just use

@OneToOne(mappedBy = "xxx") on one side and just a plain @OneToOne on the other side and let Hibernate figure out the column names. But you may need your column names to follow a specific convention or they are existing database tables.

If you are trying to associate an Employee with a User with your form then I suggest the following:

* Create a TypeConverter that can convert an Employee to a String by doing (String)employee.getId(). The other side of the conversion to an Employee takes the String id and looks up the Employee record in the database.
* Register your TypeConverter for the Employee class
* Now your field name is just user.employee and you enter the ID value. (It could be a select list with names as the value and ids as the key that gets submitted)

I suppose it is possible that you want to create a new employee record, set its id manually and have the new employee record save with the User, but I doubt it. That would require some fancy id annotations on the Employee class. Most likely you need to look up TypeConversion in Struts. I think there are older posts here or on the Struts list that I have described the process in more detail.

-D



On Jan 5, 2009, at 8:39 AM, Ice-Man wrote:

  We didn't understand what u want.
  What do u mean 'im trying to map this employee to User.'?

Ice-Man

2008/12/20 Rajesh.SriRamoju <rajesh.sriram...@gmail.com>

Hi

 Please Help me out here

What Iam trying to do is one-to-one Mapping in Appfuse2 Struts type
Steps that I did
I have an Employee model
and im trying to map this employee to User.
I have created in User as follows
---
-------
 Private Employee employee;
 @OneToOne(cascade=CascadeType.All)
@JoinColumn (name="Fk_Employee_Id",referencedColumnName="Pk_Employee_id")
   public Employee getEmployee {
       return employee;
   }

   public void setEmployee(Employee employee {
       this.employee = employee;
   }
----
----------------


in the UserForm page  I have added as follows

<s:textfield key="user.employee.id" cssClass="text large" required="true"/>

when i open the userForm and try to add new record the record is saving fine and it shows user object as saved successfully but the value which i entered
in the employee  feild was not saving in the database.
Iam unable to figure it out.
Please Help me whether iam missing any thing
or
Please Can you send me an example for One-to-One Mapping .
Thanks For ur help in advance

Regards
RajeshSr








--
View this message in context: 
http://www.nabble.com/Appfuse2-struts-type--One-to-One-Mapping--Problem-tp21104892s2369p21104892.html
Sent from the AppFuse - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@appfuse.dev.java.net
For additional commands, e-mail: users-h...@appfuse.dev.java.net



Reply via email to