Joined: Fri Jun 02, 2006 7:34 am Posts: 3
|
Hello,
I am quit new to hibernate so maybe a simple question:
I have a User & File object with a one-to-many relation.
But when the file is of a specific type there is also something like a "one-to-one" relation ..
F.I.: A user may have multiple files of type=image and only one file of type=pdf
So my User object looks a lik (snipped):
public class User implements Serializable {
private Long id;
private File pdfFile;
private List imageFiles = new ArrayList();
* @hibernate.bag name="imageFiles" lazy="false" cascade="all"
* @hibernate.collection-key column="USER_ID"
* @hibernate.collection-one-to-many class="com.company.project.model.File"
public List getImageFiles() {
return imageFiles;
}
public File getPdfFile() {
return pdfFile;
}
----
public class File implements Serializable {
private Long id;
private String type;
So how will my hibernate definition look li for the pdfFile ? Can i put a restriction on a one-to-one method so I will only get a file with type=pdf?
Thanks in advance
|
|