-->
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: The mapping attribute parent="xxx" doesn't work
PostPosted: Sun Sep 09, 2007 6:02 am 
Newbie

Joined: Sun Jul 01, 2007 9:52 am
Posts: 2
The mapping attribute parent="xxx" doesn't work

Hibernate Version: version 3.2.5

Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
   "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping package="parenttest">
   <class name="Parent" table="PARENT">
      <id name="id" column="PARENT_ID" type="long">
         <generator class="native"/>
      </id>
      <property name="name" column="NAME" type="string"/>
      
      <set name="Childs" table="CHILDS">
         <key column="CHILD_ID"/>
         <composite-element class="Child">
            <parent name="Parent"/>
            <property name="username" column="ADDED_BY_USER" type="string"/>
         </composite-element>
      </set>
   </class>
</hibernate-mapping>


But I get the Child.java class source file by hbm2java.
Code:
package parenttest;
// Generated 2007-9-9 17:42:40 by Hibernate Tools 3.2.0.b9

/**
* Child generated by hbm2java
*/
public class Child  implements java.io.Serializable {

     private String username;

    public Child() {
    }

    public Child(String username) {
       this.username = username;
    }
   
    public String getUsername() {
        return this.username;
    }

    public void setUsername(String username) {
        this.username = username;
    }
}


The code of Parent.java is OK.

So what's wrong with the mapping files? I want the Child to have the getter and setter of parent. I see the parent tag do this work in hibernate document.

Code:
   private Parent parent;
   public Parent getParent() {
      return parent;
   }

   public void setParent(Parent parent) {
      this.parent = parent;
   }


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.