Foren
self referencing Entity in liferay service builder
Alireza Goli, geändert vor 6 Jahren.
self referencing Entity in liferay service builder
New Member Beiträge: 10 Beitrittsdatum: 24.07.17 Neueste Beiträge
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
Is there any way to create self referencing entity in liferay service builder? something like:
public class comment{
public List<comment> answers;
}
thanks,
Alireza
Christoph Rabel, geändert vor 6 Jahren.
RE: self referencing Entity in liferay service builder
Liferay Legend Beiträge: 1554 Beitrittsdatum: 24.09.09 Neueste Beiträge
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.
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.
Alireza Goli, geändert vor 6 Jahren.
RE: self referencing Entity in liferay service builder
New Member Beiträge: 10 Beitrittsdatum: 24.07.17 Neueste Beiträge
Thanks