掲示板

self referencing Entity in liferay service builder

6年前 に Alireza Goli によって更新されました。

self referencing Entity in liferay service builder

New Member 投稿: 10 参加年月日: 17/07/24 最新の投稿
Hi,
Is there any way to create self referencing entity in liferay service builder? something like:

public class comment{
public List<comment> answers;
}

thanks,
Alireza
thumbnail
6年前 に Christoph Rabel によって更新されました。

RE: self referencing Entity in liferay service builder

Liferay Legend 投稿: 1555 参加年月日: 09/09/24 最新の投稿
I am guessing here that you want to have "childcomments".

You could add a long parentCommentId to the entity in the service.xml. With that parentId you could create a tree of comments. Then add a finder for parentId.

Then you could add a method to the CommentModelImpl class.

public List<comment> getSubComments() {
return persistenceSomething.findByParentId(this.commentId);
}

Note: I am not sure if the comment persistence interface is available in the ModelImpl class. You might need to add a getSubComments(long commentId) in the CommentLocalServiceImpl and call that one instead.
6年前 に Alireza Goli によって更新されました。

RE: self referencing Entity in liferay service builder

New Member 投稿: 10 参加年月日: 17/07/24 最新の投稿
Thanks