Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:3.05
I have the following component mapping and am using hbm2java which I downloaded from the jboss site. This is the latest version i've been able to find. The java code that is generated from this is not what I would expect. It appears to be overriding the user class properties / methods with those contained within the address component mapping. Is there something obvious i'm missing here ?
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 package="au.com.groupware.model">
<class name="User" table="Users">
<meta attribute="generated-class">au.com.groupware.model.UserAbstract</meta>
<meta attribute="scope-class" inherit="false">public abstract</meta>
<id name="id" column="UserId" type="string" length="50">
<generator class="assigned" />
</id>
<version name="version" column="Version" type="integer" unsaved-value="null" />
<property name="firstName" column="FirstName" type="string" not-null="true" length="100" />
<property name="lastName" column="LastName" type="string" not-null="true" length="100" />
<property name="password" column="Password" type="string" not-null="true" length="50" />
<property name="enabled" column="Enabled" type="boolean" not-null="true" />
<property name="email" column="Email" type="string" not-null="true" length="255" />
<property name="phone" column="Phone" type="string" length="20" />
<property name="mobile" column="Mobile" type="string" length="20" />
<property name="fax" column="Fax" type="string" length="20" />
<component name="address" class="au.com.groupware.model.Address">
<property name="streetAddress1" type="string" column="StreetAddress1" not-null="true" />
<property name="streetAddress2" type="string" column="StreetAddress2" />
<property name="city" type="string" column="City" not-null="true" />
<property name="postcode" type="string" column="postcode" not-null="true" />
<many-to-one name="state" class="au.com.groupware.model.State" column="StateId"
foreign-key="FK_Address_State" not-null="true" />
</component>
<set name="userRoles" table="UserRole" lazy="true" >
<key column="UserId" />
<composite-element class="au.com.groupware.model.UserRole">
<parent name="user" />
<many-to-one name="role"
class="au.com.groupware.model.Role"
column="RoleId"
not-null="true" foreign-key="FK_UserRole_Role" />
<property name="dateModified" column="DateModified" type="date" />
</composite-element>
</set>
</class>
</hibernate-mapping>
Code:
package au.com.groupware.model;
/**
* UserAbstract generated by hbm2java
*/
public class UserAbstract implements java.io.Serializable {
// Fields
private java.lang.String streetAddress1;
private java.lang.String streetAddress2;
private java.lang.String city;
private java.lang.String postcode;
private au.com.groupware.model.State state;
// Constructors
/** default constructor */
public UserAbstract() {
}
// Property accessors
/**
*/
public java.lang.String getStreetAddress1 () {
return this.streetAddress1;
}
public void setStreetAddress1 (java.lang.String streetAddress1) {
this.streetAddress1 = streetAddress1;
}
/**
*/
public java.lang.String getStreetAddress2 () {
return this.streetAddress2;
}
public void setStreetAddress2 (java.lang.String streetAddress2) {
this.streetAddress2 = streetAddress2;
}
/**
*/
public java.lang.String getCity () {
return this.city;
}
public void setCity (java.lang.String city) {
this.city = city;
}
/**
*/
public java.lang.String getPostcode () {
return this.postcode;
}
public void setPostcode (java.lang.String postcode) {
this.postcode = postcode;
}
/**
*/
public au.com.groupware.model.State getState () {
return this.state;
}
public void setState (au.com.groupware.model.State state) {
this.state = state;
}
}