Using Hibernate 3 with JDK 1.5 on a Mac OS X....
Got what I think is very simple mapping document (see below) which defines a many-to-one relationship between a resource object (resurs) and resources types (i.e. a resource must have a type). However when generating POJO classes from the HibernateToolTask the wrong type is assigned to the many-to-one property. Note, that the foreign key is not mapped to the primary key (identity) rather a unique column (string values).
Code:
<hibernate-mapping>
<class name="Resurs" table="RESURS">
<id name="id" column="RESURSID">
<generator class="identity"/>
</id>
<many-to-one name="typ" property-ref="typ" class="Resurstyp">
<column name="RESURSTYP" length="50" not-null="true"/>
</many-to-one>
<property name="beteckning">
<column name="BETECKNING" length="50" not-null="true"/>
</property>
</class>
<class name="Resurstyp" table="RESURSTYP">
<id name="id" column="RESURTYPSID">
<generator class="identity"/>
</id>
<property name="typ">
<column name="RESURSTYP" length="50" not-null="true" unique="true"/>
</property>
<property name="beteckning">
<column name="BETECKNING" length="50" not-null="true"/>
</property>
</class>
</hibernate-mapping>
The resulting Resurs.java classes starts with:
Code:
public class Resurs implements java.io.Serializable {
private Long id;
private Resurstyp typ;
private String beteckning;
The type for the typ property should be java.lang.String but instead the associated Class defined in the mapping is used. Why?
/ Thanks