I have this class
public class FolderOwner<T> {
private T owner;
}
where logically, T could be a User
public class User {
private String id;
private String lastName, firstName, middleName;
}
or a Department
public class Department {
private long id;
private String name;
}
Now, I have this class which has an attribute of an instance of FolderOwner
public class Folder {
private FolderOwner owner;
//other attributes
}
My question is how to map them in hibernate, considering those generic types in FolderOwner? I already read some answers on this forum, but they've done them using annotations. I'm quite new with Hibernate mapping and I prefer XML mapping than annotation momentarily.
My mapping for User
<class name="com.fileManagement.dataDesign.User" table="user">
<id name="id" type="string" column="id"/>
<property name="lastName" column="lastName" type="string" not-null="true"/>
<property name="firstName" column="firstName" type="string"/>
<property name="middleName" column="middleName" type="string"/>
</class>
My mapping for Department
<class name="com.fileManagement.dataDesign.Department" table="department">
<id name="id" type="int" column="id">
<generator class="native"/>
</id>
<property name="name" column="name" type="string"/>
</class>
Please help. Thanks.