-->
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: Hibernate Generating query for Subclass table
PostPosted: Mon Jul 06, 2009 2:30 pm 
Newbie

Joined: Mon Jul 06, 2009 2:00 pm
Posts: 1
Hi,
I have created mapping files for the below two files. For the sake of simplicity, assume the table names and column names
match their Java counterparts

class Prod{
Long id;
Long wid;
//In mapping file prmary key is id
//Getters and Setters generated
}

class Stage extends Prod{
//In mapping file composite key is (id, wid)
//Empty class
}

Here is the Hibernate Mapping file :

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="Prod" table="PROD"
lazy="true">
<id name="id" column="id" type="java.lang.Long"
unsaved-value="null">
<generator class="sequence">
<param name="sequence">HRCHY_NODE_SEQ</param>
</generator>
</id>

</class>



<class name="Stage" table="STAGE"
lazy="true">
<composite-id>
<key-property name="id" column="id" />
<key-property name="wid" column="wid" />
</composite-id>

</hibernate-mapping>





I write a query : " from Prod prod where id = ?";
Hibernate generates a SQL query : select id, wid from STAGE (ID, WID) in ?
Observe that in the generated SQL, the table is STAGE

Could anyone please help me as why this happens ?


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.