-->
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: JPA @IdClass/@EmbeddedId in subclasses?
PostPosted: Tue Oct 02, 2007 5:41 pm 
Newbie

Joined: Tue Oct 02, 2007 3:38 pm
Posts: 2
In our data model, we have a set of three tables:

Code:
  - Foo_Values
      o PK Column:  FOO_ID
      o PK Column:  VERSION_ID
      o PK Column:  LANGUAGE_CODE
  - Foo_Ref
      o PK Column:  FOO_ID
      o PK Column:  VERSION_ID
  - Foo_Key
      o PK Column:  FOO_ID


Using a JOINED inheritance strategy, the entities look like:

Code:
  - FooValues . . . extends
  - FooRef . . . extends
  - FooKey
      o Contains @Id fooId


FOO_ID is a unique number across all three tables so the above code works fine in a single version/language situation. However, when introducing a new version, the flaw of this approach becomes apparent, UPDATE/DELETE lacks “WHERE FOO_REF.VERSION_ID=?” and SELECT lacks the proper INNER JOIN syntax (SELECT . . . FROM FOO_VALUES T1 INNER JOIN FOO_REF T2 ON T1.FOO_ID = T2.FOO_ID AND T1.VERSION_ID = T2.VERSION_ID . . .).

I cannot supply @IdClass in the subclasses (cannot have multiple IDs in the hierarchy). And unfortunately as you move from the subs to the super, the number of key columns goes down, not up, so we have to use the least common denominator on FooKey (fooId).

Is there a way to remedy this situation other than adding the other primary key columns to the other tables? Does the above scenario force us to move to a SINGLE_TABLE inheritance strategy (which would allow us to have an @IdClass/@EmbeddedId for each table with a composite key)?

Thanks.

(Note: related to forum post http://forum.hibernate.org/viewtopic.php?t=967119 - reviewed but did not see a solution other than to modify the physical data model)


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.