0

enter image description here

I know the question might be confusing,any ways I will explain it.

Basically I have two tables. Student and Course where studentid and courseid are their corresponding primary keys.

In the Student table I have two attributes courseid and courseidbackup both are key(FK) to the course table. This is the service xml I am using, but it shows build unsuccessful.

What am I missing here? How to create service xml to achieve this ?

 <service-builder package-path="com.students.db">
<author>bugs</author>
<namespace>students</namespace>
<entity name="Student" local-service="true" remote-service="true" cache-enabled="false">
<column name="studentId" type="long" primary="true" />
<column name="studentName" type="String" />

<column name="coursesid" type="Collection" entity="Course" mapping-table="Students_Courses"/>
<column name="coursesidbackup" type="Collection" entity="Course" mapping-table="Students_Courses"/>
</entity>
<entity name="Course" local-service="true" remote-service="true" cache-enabled="false">
<column name="courseId" type="long" primary="true" />
<column name="courseName" type="String" />
<column name="courseDetails" type="String" />
<column name="students" type="Collection" entity="Student" mapping-table="Students_Courses" />
</entity>
</service-builder>
Pankaj Kathiriya
  • 4,210
  • 2
  • 19
  • 26
playmaker420
  • 1,527
  • 4
  • 27
  • 52

2 Answers2

0

You're giving the same mapping table - Students_Courses - in both cases. Try e.g. Students_Backupcourses as the second option. Otherwise I'd be puzzled how that mapping table should handle that relationship. As mentioned in the comments, typically Liferay doesn't enforce any foreign key relationship in the db model, but this would be as close as you get.

Olaf Kock
  • 46,930
  • 8
  • 59
  • 90
0

change your mapping-table="Students_Courses" to this--> mapping-table="Students_Course"

logi-kal
  • 7,107
  • 6
  • 31
  • 43