This is not solve the problem but it shows an error like not null values of
the user object on save, please suggest me to solve this problem.



dusty wrote:
> 
> If you want the new User account to save automatically when you save  
> the purchase the add cascade=CascadeType.MERGE to your @ManyToOne.   
> Although usually in a Many to One the "one" exists first but you  
> pattern could be different.
> 
> If cascade is not going to work for you then you need to save your  
> User first and then your Purchase.
> 
> On May 8, 2009, at 1:53 AM, sudhakargupta <sudhakargupta_s...@hotmail.com 
>  > wrote:
> 
>>
>> Hi Matt,
>>
>> In appfuse2 struts i written the many-to-one relationship code like  
>> this
>>
>> Purchase.java
>>
>> @ManyToOne (targetEntity=User.class)
>> @JoinColumn (name="user_id", nullable=flase)
>> private User user;
>>
>> PurchaseAction.java: (appended code)
>>
>> public List getUsers() {
>>   return userManager.getUsers(new User());
>> }
>>
>> purchaseForm.jsp: (Generated by appfuse:gen)
>>
>> <s:select name="purchase.user.id" list="users" listKey="id"
>> listValue="username"></s:select>
>>
>> It gives an error when add a new record
>>
>> object references an unsaved transient instance - save the transient
>> instance before flushing: com.ozonetel.sms.model.User; nested  
>> exception is
>> org.hibernate.TransientObjectException: object references an unsaved
>> transient instance - save the transient instance before flushing:
>> com.ozonetel.sms.model.User
>>
>> It works fine when update the already existed record
>> please suggest me how to solve this problem
>>
>>
>>
>> -----
>> ---
>> Sudhakar
>> -- 
>> View this message in context:
>> http://www.nabble.com/Struts2-Many-to-one-New-Record-Save-problem-%28JSP-Drop-down%29-tp23442385s2369p23442385.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
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@appfuse.dev.java.net
> For additional commands, e-mail: users-h...@appfuse.dev.java.net
> 
> 
> 


-----
---
Sudhakar
-- 
View this message in context: 
http://www.nabble.com/Struts2-Many-to-one-New-Record-Save-problem-%28JSP-Drop-down%29-tp23442385s2369p23457740.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