Message Boards

Hibernate RelationShip

David Gitonga, modified 10 Years ago.

Hibernate RelationShip

Junior Member Posts: 63 Join Date: 7/26/13 Recent Posts
I was wondering if there is a way around this.

If i have ParentModel and ChildModel which relatioship is one-to-many.

when i have Parent Object i can get Collection of Children
e.g.

Parent parent = ParentLocalServiceUtil.getParent(parentId);

List<Children> children = parent.getChildren();

I know service builder does not support this but could there be work around using maybe hibernate annotation somewhere?

If there someone who has done this or have an Idea please share with me.

its frustrating sometimes if i have a collection of children
i want to display with some parent parent values becomes tiresome.
e.g.

List<Children> children ;
for(Children c:children){
out.print("child Id" + c.getChildrenId()+ " ParentId "+c.getParent().getParentId()); //can this be achieved in one way or the other?
}
thumbnail
David H Nebinger, modified 10 Years ago.

RE: Hibernate RelationShip

Liferay Legend Posts: 14914 Join Date: 9/2/06 Recent Posts
Nope, you will not find any way to get there.

It has nothing to do with Hibernate. It has everything to do w/ crossing the web app class loader boundary. SB code will do that, but will not handle collections of entities (hence the lack of support for one to many or many to many relationships).

You're left to manage them all on your own.