-->
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.  [ 3 posts ] 
Author Message
 Post subject: about hbm2java
PostPosted: Fri Aug 18, 2006 6:39 am 
Beginner
Beginner

Joined: Sun Aug 13, 2006 8:48 am
Posts: 23
Hibernate version: 3.2

I want to know whether hbm2java could build java source when the hbm.xml contains <component>

my code like this

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

<hibernate-mapping>

   <class name="ergal.Customer" table="CUSTOMERS" lazy="true">
      <id name="id" type="long" column="ID">
         <generator class="increment" />
      </id>
   
      <property name="name" type="string">
         <column name="NAME" length="15" />
      </property>
      
      <component name="homeAddress" class="ergal.Address">
         <parent name="customer" />
         <property name="province" type="string" column="HOME_PROVINCE"/>
         <property name="city" type="string" column="HOME_CITY"/>
         <property name="street" type="string" column="HOME_STREET"/>
         <property name="zipcode" type="string" column="HOME_ZIPCODE"/>
      </component>
      
      <component name="comAddress" class="ergal.Address">
         <parent name="customer" />
         <property name="province" type="string" column="COM_PROVINCE"/>
         <property name="city" type="string" column="COM_CITY"/>
         <property name="street" type="string" column="COM_STREET"/>
         <property name="zipcode" type="string" column="COM_ZIPCODE"/>
      </component>
   </class>
</hibernate-mapping>


when use the hbm2java
it could create Customer.java and Address.java

this is the Address.java

Code:
package ergal;
// Generated 2006-8-18 18:07:42 by Hibernate Tools 3.2.0.beta6a



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

    // Fields   

     private String province;
     private String city;
     private String street;
     private String zipcode;

     // Constructors

    /** default constructor */
    public Address() {
    }

    /** full constructor */
    public Address(String province, String city, String street, String zipcode) {
       this.province = province;
       this.city = city;
       this.street = street;
       this.zipcode = zipcode;
    }
   
   
    // Property accessors
    public String getProvince() {
        return this.province;
    }
   
    public void setProvince(String province) {
        this.province = province;
    }
    public String getCity() {
        return this.city;
    }
   
    public void setCity(String city) {
        this.city = city;
    }
    public String getStreet() {
        return this.street;
    }
   
    public void setStreet(String street) {
        this.street = street;
    }
    public String getZipcode() {
        return this.zipcode;
    }
   
    public void setZipcode(String zipcode) {
        this.zipcode = zipcode;
    }

}



but there is a problem that it doesn't contains
Code:
private Customer customer;

    /** full constructor */
    public Address(String province, String city, String street, String zipcode, mypack.Customer customer) {
        this.province = province;
        this.city = city;
        this.street = street;
        this.zipcode = zipcode;
        this.customer = customer;


Other question:

whether the filed "customer" and the construct method "public Address(String province, String city, String street, String zipcode, mypack.Customer customer)" must be there
Why?
what is the real meaning of the filed "customer" and what it is used for?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 18, 2006 8:25 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
should be asked in the tools forum.

but generally speaking this should just work fine, have you used the latest version of hibernate tools (3.2b6) or is some earlier version ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 18, 2006 11:15 am 
Beginner
Beginner

Joined: Sun Aug 13, 2006 8:48 am
Posts: 23
ok thx
I will


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