Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Simon Bruns
ServiceBuilder: generated code problems
June 26, 2013 7:24 AM
Answer

Simon Bruns

Rank: New Member

Posts: 4

Join Date: April 21, 2013

Recent Posts

Hi everyone,

I'm pretty new to liferay and the whole service as DB idea. I wanted to create a service.xml, which describes the RIS format. This is a simplified version for test purposes with only author and title. The basic idea is to enable the user to search for papers by inputing either the author or the title. If you request by author all his corresponding titles are accessible.

After generating the code this error emerges:

Compiling 2 source files to /Users/sbruns/Liferay/liferay-plugins-sdk-6.1.1/portlets/RIS-portlet/docroot/WEB-INF/service-classes
----------
1. ERROR in /Users/sbruns/Liferay/liferay-plugins-sdk-6.1.1/portlets/RIS-portlet/docroot/WEB-INF/service/com/sample/portlet/RIS/model/AuthorClp.java (at line 188)
value = getTitle().compareTo(author.getTitle());
^^^^^^^^
The method getTitle() is undefined for the type AuthorClp
----------
2. ERROR in /Users/sbruns/Liferay/liferay-plugins-sdk-6.1.1/portlets/RIS-portlet/docroot/WEB-INF/service/com/sample/portlet/RIS/model/AuthorClp.java (at line 188)
value = getTitle().compareTo(author.getTitle());
^^^^^^^^
The method getTitle() is undefined for the type Author
----------
----------
3. ERROR in /Users/sbruns/Liferay/liferay-plugins-sdk-6.1.1/portlets/RIS-portlet/docroot/WEB-INF/service/com/sample/portlet/RIS/model/TitleClp.java (at line 188)
value = getAuthor().compareTo(title.getAuthor());
^^^^^^^^^
The method getAuthor() is undefined for the type TitleClp
----------
4. ERROR in /Users/sbruns/Liferay/liferay-plugins-sdk-6.1.1/portlets/RIS-portlet/docroot/WEB-INF/service/com/sample/portlet/RIS/model/TitleClp.java (at line 188)
value = getAuthor().compareTo(title.getAuthor());
^^^^^^^^^
The method getAuthor() is undefined for the type Title
----------
4 problems (4 errors)

BUILD FAILED

Code:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 6.1.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_6_1_0.dtd">
<!-- PackagePath "com.sample.portlet.RIS" -->
<service-builder package-path="com.sample.portlet.RIS">
<author>sbruns</author>
<namespace>RIS_DB</namespace>

<!-- RIS Table -->

<entity name="RIS" local-service="true" remote-service="false">

<!-- PK fields -->

<column name="RISId" type="long" primary="true" id-type="identity" />


<!-- Note: - add groupId, companyId, etc. so each organisation has its
own data -->
<!-- Group instance -->

<column name="groupId" type="long" />

<!-- Audit fields -->

<column name="companyId" type="long" />
<column name="userId" type="long" />
<column name="userName" type="String" />
<column name="createDate" type="Date" />
<column name="modifiedDate" type="Date" />

<!-- actual RIS Table content -->

<column name="titleId" type="long" />
<column name="authorId" type="long" />

<!-- Summarization of Titles for request -->

<column name="titles" type="Collection" entity="Title"
mapping-key="titleId">
</column>

<!-- Summarization of Authors for request -->

<column name="authors" type="Collection" entity="Author"
mapping-key="authorId">
</column>

</entity>

<!-- Title Table -->

<entity name="Title" local-service="true" remote-service="false">

<!-- PK fields -->

<column name="titleId" type="long" primary="true" id-type="increment" />
<column name="authorId" type="long" />

<!-- Group instance -->

<column name="groupId" type="long" />

<!-- Audit fields -->

<column name="companyId" type="long" />


<!-- Title Table content -->

<column name="name" type="String">
</column>
<column name="author" type="Collection" entity="Author"
mapping-key="Author_Title">
</column>
<order>
<order-column name="author" order-by="asc" />
</order>

<!-- findByAuthorId - collection of Authors for the active title -->

<finder return-type="Collection" name="authorId">
<finder-column name="authorId"></finder-column>
</finder>

</entity>

<!-- Author Table -->

<entity name="Author" local-service="true" remote-service="false">

<!-- PK fields -->

<column name="authorId" type="long" primary="true" id-type="increment" />

<!-- Group instance -->

<column name="groupId" type="long" />

<!-- Audit fields -->

<column name="companyId" type="long" />


<!-- Other fields -->

<column name="name" type="String">
</column>
<column name="title" type="Collection" entity="Title"
mapping-key="Author_Title">
</column>
<order>
<order-column name="title" order-by="asc" />
</order>

<!-- findByTitleId - collection of Titles for the active author author -->

<finder return-type="Collection" name="titleId">
<finder-column name="titleId"></finder-column>
</finder>

</entity>

</service-builder>


How can I solve this problem?

Thank you very much,
Simon.
David H Nebinger
RE: ServiceBuilder: generated code problems
June 27, 2013 10:14 AM
Answer

David H Nebinger

Community Moderator

Rank: Liferay Legend

Posts: 11795

Join Date: September 1, 2006

Recent Posts

Although you can define collections in your entities, the generated code will not actually provide access to them. The issue relates to the code which allows crossing the class loader boundary between web apps and how difficult it is to get the collections right (as far as adding, removing, or updating an item in the collection).

SB works really well for simple entities. When you need to access a separate collection of entities, define the separate entity and pull the collection manually.

I know it's not what you're used to if you're from a Hibernate/JPA background, but it is what it is...
Simon Bruns
RE: ServiceBuilder: generated code problems
July 4, 2013 3:06 AM
Answer

Simon Bruns

Rank: New Member

Posts: 4

Join Date: April 21, 2013

Recent Posts

So I guess in my example, I would have to create a mapping-table for author and title. And for the actual problem a mapping table for all components of RIS.

I think i get the basic idea. Thanks for the quick reply. emoticon