Hi All,
I'm trying inheritance OR mapping and following table per class hierarchy. While trying to create ddl using schema export I'm getting this
[schemaexport] Aug 29, 2006 8:27:03 PM org.hibernate.cfg.HbmBinder bindSubclass
[schemaexport] INFO: Mapping subclass: com.look.hub.model.user.PanelistImpl -> users
BUILD FAILED
/home/leema/test/hibernateTools/build.xml:26: Schema text failed: Could not read mapping document from file: /home/leema/test/hibernateTools/src/com/model/user/User.hbm.xml
User.hbm.xml
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.model.user.AgeLifeStage"
table="life_stage">
<id name="id"
type="com.util.hibernate3.StringIdentifierHibernate3Type"
column="life_stage_id">
<generator class="assigned" />
</id>
<property name="name" type="string"></property>
</class>
<class name="com.model.user.Address" table="address">
<id name="id"
type="com.util.hibernate3.StringIdentifierHibernate3Type"
column="address_id">
<generator class="assigned" />
</id>
</class>
<class name="com.model.user.Credentials"
table="credentials">
<id name="id"
type="com.util.hibernate3.StringIdentifierHibernate3Type"
column="credentials_id">
<generator class="assigned" />
</id>
<subclass
name="com.user.UsernameAndPasswordCredentials" extends="">
<property name="hashedPassword" type="string"
column="hashed_password" />
</subclass>
</class>
<class name="com.model.user.ProfileQuestion"
table="ProfileQuestions">
<id name="profileQuestionId"
type="com.util.hibernate3.StringIdentifierHibernate3Type">
<generator class="assigned" />
</id>
<property name="question" type="string" />
</class>
<class name="com.model.user.ProfileQuestionResponse"
table="ProfileQuestionResponse">
<id name="id"
type="com.util.hibernate3.StringIdentifierHibernate3Type">
<generator class="assigned" />
</id>
<many-to-one name="profileQuestion"
column="profile_question_id" />
<property name="response" type="string" />
</class>
<class name="com.model.user.User" table="users">
<id name="id"
type="com.util.hibernate3.StringIdentifierHibernate3Type"
column="user_id">
<generator class="assigned" />
</id>
<discriminator type="string" column="type" />
<subclass name="com.model.user.BaseUser"
discriminator-value="baseuser" extends="">
<property name="username" column="user_name" />
<property name="email" column="email"/>
<property name="active" column="active"/>
<many-to-one name="credentials" column="credentials_id"
unique="true" cascade="all" />
<subclass name="com.model.user.BaseClient"
discriminator-value="baseclient"
proxy="com.model.user.Client">
<property name="name" />
<subclass
name="com.model.user.RestrictedPrivClient"
discriminator-value="restrictedclient">
</subclass>
<subclass name="com.model.user.FullPrivClient"
discriminator-value="fullclient">
</subclass>
</subclass>
<subclass name="com.model.user.AdministratorImpl"
discriminator-value="admin"
proxy="com.model.user.Administrator">
</subclass>
<subclass name="com.model.user.PanelistImpl"
discriminator-value="panelist"
proxy="com.look.hub.model.user.Panelist">
<property name="firstName" column="first_name" />
<property name="lastName" column="last_name" />
<property name="birthdate" column="birth_date" />
<property name="male" column="male" />
<many-to-one name="lifeStage" column="life_stage_id" />
<many-to-one name="address" column="address_id" unique="true"/>
<set name="profileQuestionResponses">
<key column="user_id" />
<one-to-many class="com.model.user.ProfileQuestionResponse" />
</set>
</subclass>
</subclass>
</class>
</hibernate-mapping>
PanelistImpl.java
Code:
public class PanelistImpl extends BaseUser implements Panelist {
private boolean male;
private Address address;
private AgeLifeStage lifeStage;
private String firstName = "";
private String lastName = "";
private Date birthDate;
private Set profileQuestionResponses;
public void setProfileQuestionResponses(Set profileQuestionResponses) {
this.profileQuestionResponses = profileQuestionResponses;
}
public Set getProfileQuestionResponses() {
return profileQuestionResponses;
}
public Date getBirthDate() {
return birthDate;
}
public void setBirthDate(Date birthDate) {
this.birthDate = birthDate;
}
public boolean getMale() {
return male;
}
public void setMale(boolean male) {
this.male = male;
}
public Address getAddress() {
return address;
}
public void setAddress(Address address) {
this.address = address;
}
public AgeLifeStage getLifeStage() {
return lifeStage;
}
public void setLifeStage(AgeLifeStage lifeStage) {
this.lifeStage = lifeStage;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
}
By commenting the subclass elements unser panelist, its running.. What went wrong in my association mapping? As the association to address and AgeLifeStage in unidirectional, i didn't specified anything there..
Can anyone help me out to resolve this?
Thanks in advance
[/code]