-->
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.  [ 4 posts ] 
Author Message
 Post subject: TABLE_PER_CLASS warning - also need example of this mapping
PostPosted: Thu Mar 06, 2008 10:37 pm 
Regular
Regular

Joined: Wed Dec 21, 2005 6:57 pm
Posts: 70
Using TABLE_PER_CLASS (unfortunately) we are having an issue converting to annotations. Here are the mappings for two of the classes in the hierarchy:

Hibernate version:
core 3.2.5, annotations 3.2.1

Mapping documents:
Code:
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@Table(name="value")
@Proxy(lazy=false)

@Entity
@Table(name="stringvalue")
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@Proxy(lazy=false)
@Embeddable
@PrimaryKeyJoinColumn(name="cdfvalue_guid")


(we added the @Inheritance annotation to the subclass, but have also tried it without that annotation)

Here is the Warning output we get
Code:
    [exec] 21:27:04,515 WARN  [AnnotationBinder] Root entity should not hold an PrimaryKeyJoinColum(
s), will be ignored
    [exec] 21:27:04,515 WARN  [AnnotationBinder] Root entity should not hold an PrimaryKeyJoinColum(
s), will be ignored


What does this error mean? If the PrimaryKeyJoinColumn does not join up the superclass table with the subclass tables, how should we specify the join?

The annotation docs do not fully document this mapping style (only the superclass mapping is indicated). Can someone point us to an example of TABLE_PER_CLASS, or post a working mapping with annotations?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 08, 2008 1:11 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
TABLE_PER_CLASS does not need any PKJC information. What are you trying to map here?

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Details on mapping
PostPosted: Mon Mar 10, 2008 9:43 am 
Regular
Regular

Joined: Wed Dec 21, 2005 6:57 pm
Posts: 70
I have a list of user-defined values that can be strings or numbers. The superclass has data like the value name, etc. and the sub-classes hold a numeric or a string value, respectively.

The sub-class tables have a key that is the same as the parent GUID.

I have written DB scripts to move the data up into the parent table and will change to table-per-hierarchy (which should have been used in the first place), but for the overall community it would be good to post an example of the mapping. The annotations docs (section 2.2.4.1) only show how to annotate the superclass, but don't show an example of how the subclasses are annotated. I'd say it's a doc bug.

Do they just use the PKs of both classes, assuming that it is a joing on PK? Do people need to specify the strategy at the subclass level as well? etc.

Here are the old mappings:

Code:
*        @   <<removed>> hibernate.class
*         table="customvalue"
*/
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@Table(name="customvalue")
@Proxy(lazy=false)
public abstract class CustomValue

@Entity
@Table(name="customstringvalue")
@Proxy(lazy=false)
@Embeddable
@PrimaryKeyJoinColumn(name="customvalue_guid")
public class CustomStringValue extends CustomValue


thanks for taking time to post a reply!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 10, 2008 7:19 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
open a JIRA issue for the doc enhancement.

Basically, just get rid of @PrimaryKeyJoinColumn. There is no FK involved in a table per class. For a given instance, the data is in one and only one table.

_________________
Emmanuel


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

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.