-->
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.  [ 2 posts ] 
Author Message
 Post subject: Table per subclass mapping
PostPosted: Mon Nov 21, 2005 10:43 am 
Newbie

Joined: Mon Nov 21, 2005 10:35 am
Posts: 1
Hi, I'm implementing a "table per subclass" mapping, that is, i have classes that all inherit from a common parent class, that has only 2 properties ('id' and 'date'). My mapping file is:

Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" assembly="Assembly1">
   <class name="it.commons.BaseObject" table="dummy" >
      <id name="id" column="id" type="Int32">
         <generator class="sequence">
            <param name="sequence">seq1</param>
         </generator>
      </id>
      <property name="date" column="date" type="DateTime"/>
   </class>
      
   <joined-subclass name="it.commons.User" table="users" extends="it.commons.BaseObject">         
         <key column="id"/>
         <property name="nick" column="nickname" type="String" />
         <property name="name" column="name" type="String" />
         <property name="password" column="password" type="String" />
   </joined-subclass>
</hibernate-mapping>


I want nhibernate to store all the data of an object of type "User" in the table named "users" (I'm using postgres8.1 and table "users" inherits from table "dummy"). With this mapping, nhibernate puts a row in table "dummy", and a row in table "users". What's the problem with my mapping file?

Thanks in advance!
Marco


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 21, 2005 4:47 pm 
Try :

Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" assembly="Assembly1">
   <class name="it.commons.BaseObject" table="dummy" >
      <id name="id" column="id" type="Int32">
         <generator class="sequence">
            <param name="sequence">seq1</param>
         </generator>
      </id>
      <property name="date" column="date" type="DateTime"/>
   </class>
     
   <class name="it.commons.User" table="users">
      <id name="id" column="id" type="Int32">
         <generator class="sequence">
            <param name="sequence">seq1</param>
         </generator>
      </id>
      <property name="date" column="date" type="DateTime"/>         
      <property name="nick" column="nickname" type="String" />
      <property name="name" column="name" type="String" />
      <property name="password" column="password" type="String" />
   </class>
</hibernate-mapping>


Top
  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.