-->
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: EmbeddedId, Inheritance and SecondaryTable
PostPosted: Thu Nov 11, 2010 10:04 am 
Newbie

Joined: Thu Aug 28, 2008 6:00 am
Posts: 6
Hello, I'm using Hibernate version 3.3.2.GA with annotations.

I have inheritance between two classes, the former:

Code:
@Entity
@Table(name = "SUPER_CLASS")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(
    name="DISCR_TYPE",
    discriminatorType= DiscriminatorType.STRING
)
@org.hibernate.annotations.Entity(mutable = false)
public class SuperClass { }


The subclass is mapped with a secondary table:

Code:
@Entity
@DiscriminatorValue("VALUE")
@org.hibernate.annotations.Entity(mutable = false)
@SecondaryTable(name = "V_SECONDARY_TABLE",
        pkJoinColumns = @PrimaryKeyJoinColumn(name = "ID", referencedColumnName = "ID"))
public class SubClass extends SuperClass  {
   @Embedded
    public Field getField() {
        return getField;
    }
}

Where the field is composed of two different fields

Code:
@Embeddable
public Field HistoryInfo {
   @Column("FIELD_1") String field1
}


Now when I create a query on SubClass the FIELD_1 is searched on the SuperClass, even if it's defined in the subclass.

I can't set the table in the column field, because the Field class it's reused somewhere. I need to specify it in SubClass class.

How do I specify that the field should be in the secondary table?


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.