-->
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: Inheritance Question
PostPosted: Wed Dec 26, 2007 3:34 am 
Newbie

Joined: Tue Dec 25, 2007 12:45 pm
Posts: 1
Hibernate version: 3.*
Name and version of the database you are using: mySql 5.03

We have 2 tables : parent_table and child_table
the child_table id is equal to the parent_table id.

each table has its own hibernate class:

Code:
@Entity
@Inheritance(strategy=InheritanceType.JOINED)
@Table(name = "parent_table", uniqueConstraints = {})
public class ParentTable implements java.io.Serializable {
...
    private int id;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "ID", unique = true, nullable = false, insertable = true, updatable = true)
    public int getId() {
   return this.id;
    }

    public void setId(int id) {
   this.id = id;
    }
...

}

@Entity
@Table(name = "child_table", uniqueConstraints = {})
public class ChildTable extends ParentTable {
    ...
}




ChildTable expands the ParentTable with some very large data.

we wish to retrieve only the ParentTable information since the information in the child is very large blobs data. However, even when we retrieve by

Code:
getEntityManager().find(ParentTable.class, id)


the result is ChildTable instance with all its data.

The id of the parent table is generated automatically.
when we used inheritance strategy = TABLE_PER_CLASS we fail for the generated id issue.

Is there a way to retrieve the ParentTable object?

Your help will be really appreciated.
Thanks!


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.