Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
sheela mk
One to many Relationship using Service builder
May 28, 2012 11:13 PM
Answer

sheela mk

Rank: Regular Member

Posts: 112

Join Date: February 16, 2012

Recent Posts

hai..Everbody,

Pls chk my program,Let me know whr i'm going wrong..

And also..These use of finder tags,from which what method is generated and where it is generated????


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 6.0.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_6_0_0.dtd">
<service-builder package-path="com.test">
<author>sourceone</author>
<namespace>A</namespace>
<entity name="PRUser" local-service="true" remote-service="false">
<column name="prUserId" type="long" primary="true" />
<column name="firstName" type="String" />
<column name="lastName" type="String" />

<column name="address1" type="String" />
<column name="address2" type="String" />
<column name="city" type="String" />
<column name="state" type="String" />
<column name="postalCode" type="String" />
<column name="country" type="String" />
<column name="phoneNumber" type="String" />
<column name="email" type="String" />
<column name="birthDate" type="Date" />
<column name="male" type="boolean" />
<column name="userId" type="long" />
<column name="companyId" type="long" />
<column name="groupId" type="long" />

// I guess it should generate getuserRegistrations() in PRUser Model class....But..after doing service service builder
i'm not getting that method,,???

<column name="userRegistrations" type="Collection" entity="PRRegistration"
mapping-key="prUserId" />



<order by="asc">
<order-column name="lastName" case-sensitive="false" />
</order>

What are use of these tags,,pls gve me idea..name of the method generated on passing what parameter..and returns Collection of What??


<finder name="G_LN" return-type="Collection">
<finder-column name="groupId" />
<finder-column name="lastName" />
</finder>
<finder name="G_E" return-type="Collection">
<finder-column name="groupId" />
<finder-column name="email" />
</finder>
<finder name="G_U" return-type="Collection">
<finder-column name="groupId" />
<finder-column name="userId" />

</finder>



</entity>


<entity name="PRRegistration" local-service="true"
remote-service="false">
<column name="registrationId" type="long" primary="true" />
<column name="prUserId" type="long" />
<column name="datePurchased" type="Date" />
<column name="howHear" type="String" />
<column name="wherePurchased" type="String" />
<column name="serialNumber" type="String" />
<column name="productId" type="long" />
<column name="companyId" type="long" />
<column name="groupId" type="long" />



<finder name="GroupId" return-type="Collection">
<finder-column name="groupId" />
</finder>
<finder name="G_RU" return-type="Collection">
<finder-column name="groupId" />
<finder-column name="prUserId" />
</finder>
<finder name="G_DP" return-type="Collection">
<finder-column name="groupId" />
<finder-column name="datePurchased" />
</finder>
<finder name="G_SN" return-type="Collection">
<finder-column name="groupId" />
<finder-column name="serialNumber" />
</finder>

</entity>




</service-builder>
sheela mk
RE: One to many Relationship using Service builder
May 28, 2012 11:23 PM
Answer

sheela mk

Rank: Regular Member

Posts: 112

Join Date: February 16, 2012

Recent Posts

K..I got to know finder tags will generate methods in EntityPersistence class...ie a interface..

But I didnt get to know about..one to many relationship ..??Pls let me clear...
sheela mk
RE: One to many Relationship using Service builder
May 28, 2012 11:43 PM
Answer

sheela mk

Rank: Regular Member

Posts: 112

Join Date: February 16, 2012

Recent Posts

hai..I got to know..that method also generated in EntityPersistence interface..

Its impl is in EntityPersistenceImpl class...But How to get that method from persistence to my portlet class..I mean Layering???
Subhash Shah
RE: One to many Relationship using Service builder
May 28, 2012 11:55 PM
Answer

Subhash Shah

Rank: Junior Member

Posts: 77

Join Date: November 29, 2011

Recent Posts

sheela mk:
But How to get that method from persistence to my portlet class..I mean Layering???


You should use <Entity-name>LocalServiceUtil class to use/call the method from your portlet.
sheela mk
RE: One to many Relationship using Service builder
May 29, 2012 2:12 AM
Answer

sheela mk

Rank: Regular Member

Posts: 112

Join Date: February 16, 2012

Recent Posts

Hey,,Can U eloborate ..what you said...
sheela mk
RE: One to many Relationship using Service builder
May 29, 2012 4:42 AM
Answer

sheela mk

Rank: Regular Member

Posts: 112

Join Date: February 16, 2012

Recent Posts

Hai..Thanks for reply..I got to knw..how to achieve it..
Juan Gonzalez
RE: One to many Relationship using Service builder
May 29, 2012 10:26 AM
Answer

Juan Gonzalez

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1872

Join Date: October 28, 2008

Recent Posts

sheela mk:
Hai..Thanks for reply..I got to knw..how to achieve it..


Please can you tell how did you solve it, so others can read the correct answer....

Thanks!
Michele Zanarotti
RE: One to many Relationship using Service builder
January 31, 2013 9:11 AM
Answer

Michele Zanarotti

Rank: Junior Member

Posts: 74

Join Date: February 20, 2012

Recent Posts

'Service Builder generates a getRegistrations() method in PRUser objects...'

That's exactly what the book 'Liferay In Action' is saying at page 87 (2012 edition), after showing how to relate PRUser and PRRegistration.

Precisely the book had to say 'getUserRegistrations()', but i thought it as a typo. In any case i downloaded the sources of the book examples and
even there this method does not exist.

Furthermore the book does not use this method, so I can't know how to use it or if I'm doing something wrong.

Can we have some clarifying explanation from the liferay team ? I browsed forums and tutorials for a week without any solution, and only more questions raised emoticon

I'm using Liferay 6.1 GA1.