Foren

Home » Liferay Portal » English » 3. Development

Kombinierte Ansicht Flache Ansicht Baumansicht
Threads [ Zurück | Nächste ]
toggle
Sunil Kulkarni
Unable to add new method in XXXPersistenceImpl class
4. Mai 2013 12:14
Antwort

Sunil Kulkarni

Rang: Junior Member

Nachrichten: 94

Eintrittsdatum: 24. Juni 2011

Neue Beiträge

Hello All,

I am using LR 6.1.1 CE version.

I have created a service.xml with following

 1<?xml version="1.0" encoding="UTF-8"?>
 2<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 6.1.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_6_1_0.dtd">
 3<service-builder package-path="com.book"
 4    auto-namespace-tables="false">
 5    <author>Sunil Kulkarni</author>
 6    <namespace>MyHook</namespace>
 7
 8    <entity name="Book" local-service="true" remote-service="false">
 9        <column name="messageId" type="long" primary="true" />
10
11        <column name="title" type="String" />
12        <column name="description" type="String" />
13        <column name="createdBy" type="long" />
14        <column name="createdDate" type="Date" />
15        <column name="modifiedBy" type="long" />
16        <column name="modifiedDate" type="Date" />
17
18    </entity>
19
20</service-builder>


and then I run the service builder. Service Builder has generated all the requried service and persistence layer classes.
Now I am trying to add new methos in BookPersistenceImpl class and then run the service builder.

Service builder overwrites all the newly added methods from BookPersistenceImpl class.

How do I new methods at persistnce layer which are generated by Service Builder
David H Nebinger
RE: Unable to add new method in XXXPersistenceImpl class
5. Mai 2013 08:12
Antwort

David H Nebinger

Community Moderator

Rang: Liferay Legend

Nachrichten: 11064

Eintrittsdatum: 1. September 2006

Neue Beiträge

You can't do this. The persistence layer is totally owned by SB. The only place you can (or should) add code is the XXXLocalServiceImpl class. In this class you can add methods to support alternative queries, DQ, and the like.
Mika Koivisto
RE: Unable to add new method in XXXPersistenceImpl class
7. Mai 2013 16:06
Antwort

Mika Koivisto

LIFERAY STAFF

Rang: Liferay Legend

Nachrichten: 1512

Eintrittsdatum: 7. August 2006

Neue Beiträge

You can create XXXFinderImpl where you add your custom finders that are more complex than what SB can autogenerate from service.xml.
Sunil Kulkarni
RE: Unable to add new method in XXXPersistenceImpl class
11. Mai 2013 09:06
Antwort

Sunil Kulkarni

Rang: Junior Member

Nachrichten: 94

Eintrittsdatum: 24. Juni 2011

Neue Beiträge

Thanks for replying .
However, We can only add finders methods into it.

In my case, I have created one table called as BookCatagory, where I am maintaining the bookid and catagoryid. This is a transaction table and I do not want to provide the service over this table (service Builder generated classes).

When user adds Books entry, I want to insert the data into BookCatagoty table.The BookCatagory table is updated, deleted with Books table.

In this case, how do I approach this issue.
David H Nebinger
RE: Unable to add new method in XXXPersistenceImpl class
11. Mai 2013 09:31
Antwort

David H Nebinger

Community Moderator

Rang: Liferay Legend

Nachrichten: 11064

Eintrittsdatum: 1. September 2006

Neue Beiträge

You would still define the BookCategory entity. Your BookLocalServiceImpl class can do the creates, adds, and removes as necessary, but it still needs to be defined as an entity.

There is no support in SB for 'hidden' entities that you're trying to define. All entities are public, and the API to access those entities are public also.

We have a similar setup where we have entities that are not meant to be used by external plugins, we deal with this by notifying the team that the methods are not meant to be used. The XxxLocalServiceImpl class that uses the internal entities will make necessary changes using the API in just the way you're describing. It all works just fine.
Alain Dresse
RE: Unable to add new method in XXXPersistenceImpl class
11. Mai 2013 10:36
Antwort

Alain Dresse

Rang: Junior Member

Nachrichten: 95

Eintrittsdatum: 18. Juli 2011

Neue Beiträge

I believe you can create an entity without the corresponding *Service* classes if you set bothe the localservice and remotes vice attributes to false for your BookCategory entity.