-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: one-to-one with a restriction?
PostPosted: Fri Jul 14, 2006 6:21 am 
Newbie

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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.