Hey everyone - i have a simple persistence mapping question which i am unsure
about:

I have a Category class which can many images - an image can only be in one
category. How do i map this? I've had a go but not sure if i'm correct:

===== Category.class ======

@Entity
@Table(name="categories")
public class Category extends BaseObject {

 protected Set<Image> images = new HashSet<Image>();

//getter
   @OneToMany(
     targetEntity=Image.class,
     mappedBy="???"
    )
    public Set<Image> getImages(){
        return images;
    }
}
===== Image.class =====
public class Image extends BaseObject {

protected Long categoryId;

//getter
    
  public Long getCategoryId() {
        return categoryId;
  }

}

Thats as far as i have got? Do i need a join table? Surely if the Image
object just contains a category ID that will be fine? Any suggestions about
how to map this would be very greatful :)

Many Thanks Sion
-- 
View this message in context: 
http://www.nabble.com/javax.persistence-Design-Question-tf3674600s2369.html#a10267807
Sent from the AppFuse - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to