Hello,
I am trying to do the following:
[code]
@Entity
MyObject {
@Id
protected String id;
@OneToMany(mappedBy = "parent", cascade = CascadeType.PERSIST, fetch = FetchType.LAZY)
protected Set<ChildObject> children;
}
@Entity
ChildObject {
@Id
protected String id;
@ManyToOne()
@JoinColumn(name = "parent")
protected MyObject parent;
}
[/code]
I wonder if it is possible to have only the ID of the MyObject in ChildObject instead of fetching the whole MyObject.
I only need the association from MyObject to ChildObject. When I need ChildObject I just need the ID of MyObject and not the whole MyObject. As ChildObject table stores the ID of the MyObject I though that there would be a way to map an ID like:
[code]
... MyObject stays the same.
@Entity
ChildObject {
@Id
protected String id;
@ManyToOne()
@JoinColumn(name = "parent")
protected String parent;
}
[/code]
In my implementation "parent" is mapped to an XML attribute and it really seems like a performance hit to fetch every MyObject for every ChildObject when I want to list (as XML) all the ChildObjects with the parent ID attribute.
Any suggestions are welcome.
Thanks
[Message sent by forum member 'marlor' (marlor)]
http://forums.java.net/jive/thread.jspa?messageID=297445