-->
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.  [ 1 post ] 
Author Message
 Post subject: @OneToOne annotation, composite key, Reverse Engineering
PostPosted: Fri May 15, 2009 12:09 pm 
Newbie

Joined: Fri May 15, 2009 11:38 am
Posts: 1
I generated my annotated code from an existing DB using the RevEng tool. I have a TblDetail table that has a composite primary key:

@Embeddable
public class TblDetailId
{
String mission;
String type;
int num;
}

I have a TblOrbit table that also has a composite primary key, with the same fields:

@Embeddable
public class TblOrbitId
{
String mission;
String type;
int num;
}

(It goes without saying that the corresponding table fields have the same names in the DB, and that I didn't make the DB and have little to no say in the structure.) The TblOrbit table has a foreign key onto the TblDetail table, so the RevEng tool generates:

public class TblDetail
{
TblOrbit orbit;

@OneToOne(fetch = FetchType.LAZY, mappedBy = "tblDetail")
public TblOrbit getOrbit()...
}

(Obviously, I left a lot out for brevity)

When I try to load a row from TblDetail, which is actually part of a one-to-many set from TblOverview, I get the exception:

org.hibernate.TypeMismatchException: Provided id of the wrong type for class TblOrbit. Expected: class TblOrbitId, got class TblDetailId

I have seen similar postings, but I just don't understand the problem or the solution. To make matters worse, there is ANOTHER table with a one-to-one with TblDetail, and it has, you guessed it, the same composite key structure.

I know this is the problem because I can comment out the one-to-one fields and my test case runs. Any help is appreciated.

Regards,
reilly.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.