掲示板

how to defining relationship in service.xml !!!

11年前 に Ashwani Kumar によって更新されました。

how to defining relationship in service.xml !!!

Junior Member 投稿: 26 参加年月日: 12/10/19 最新の投稿
Hi All,

I want to create one-to-many relation betwen "teacher" and "course" entites..ie. One teacher can teach multiple courses.. so i created the below service.xml
<namespace>student</namespace>
<entity name="teacher" local-service="true" >
<column name="tID" type="long" primary="true" />
<column name="name" type="String" />
<column
name="courseList"
type="Collection"
entity="course"
mapping-key="tID" />
</entity>
<entity name="course" local-service="true" >
<column name="courseID" type="long" primary="true" />
<column name="name" type="String" />
<column name="tID" type="long" />
</entity>


after running ant build-service it is not creating getCourseList() function for teacher object...Is my service.xml is valid??

Thanks in advance..

-
Ashwani
thumbnail
11年前 に Priyanka Dhingra によって更新されました。

RE: how to defining relationship in service.xml !!!

Liferay Master 投稿: 501 参加年月日: 11/12/20 最新の投稿
hi
please check with
teacherPersistence.getcourses(pk);
11年前 に Ashwani Kumar によって更新されました。

RE: how to defining relationship in service.xml !!!

Junior Member 投稿: 26 参加年月日: 12/10/19 最新の投稿
Hi Priyanka,

Thanks for your quick reply...but as per the doument..on liferay.com.. It teacher class object should be injected to Course Class.

and the method like getTeacher() should be availble in Course class object..

But it is not working in this manner...


-
Ashwani..
thumbnail
11年前 に Priyanka Dhingra によって更新されました。

RE: how to defining relationship in service.xml !!!

Liferay Master 投稿: 501 参加年月日: 11/12/20 最新の投稿
go through this link
thumbnail
11年前 に Nicolas Tamayo によって更新されました。

RE: how to defining relationship in service.xml !!!

Junior Member 投稿: 29 参加年月日: 12/10/03 最新の投稿
Hi Ashwani Kumar.

you must do this modification to your service.xml Document.


<namespace>student</namespace>
<entity name="teacher" local-service="true">
<column name="tID" type="long" primary="true" />
<column name="name" type="String" />
<column name="courseList" type="Collection" entity="course" mapping-key="tID" />
</entity>
<entity name="course" local-service="true">
<column name="courseID" type="long" primary="true" />
<column name="name" type="String" />
<column name="tID" type="long" />

<!-- The Addition -->
<finder name="TeacherID" return-type="teacher">
<finder-column name="tID" />
</finder>

</entity>


with this addition in your service.xml Document when you generate the services, in your courseLocalServiceImpl. you will do a method that call the couserPersistence.findByTeacherID(long tID); in order of return the Teacher for this course.

I hope it helps you.