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?