[jboss-user] [EJB 3.0] - Re: ClassCastException on OneToOne merge

justinb do-not-reply at jboss.com
Tue Aug 15 06:02:36 EDT 2006


I had a look and it seems I went against autogenerating the Employment id and instead made the Employment id be the same (String) as the Employee id.

I dropped the @SequenceGenerator on the Employment side and had the following in the Employee class:

@OneToOne(optional = false, cascade = {CascadeType.ALL})
  | @PrimaryKeyJoinColumn
  | public Employment getEmployment() {
  |       return employment;
  | }

Then, when ever I make the Employee persistent, I just first make sure that the Employment is not null, and has the same id as the Employee.

I think that was a gross work around, but at the time I needed to get it working.

Hope that helps,
Justin

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3965210#3965210

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3965210



More information about the jboss-user mailing list