Fórumok

Unable to add new method in XXXPersistenceImpl class

Sunil Kulkarni, módosítva 10 év-val korábban

Unable to add new method in XXXPersistenceImpl class

Junior Member Bejegyzések: 94 Csatlakozás dátuma: 2011.06.24. Legújabb bejegyzések
Hello All,

I am using LR 6.1.1 CE version.

I have created a service.xml with following

<!--?xml version="1.0" encoding="UTF-8"?-->

<service-builder package-path="com.book" auto-namespace-tables="false">
	<author>Sunil Kulkarni</author>
	<namespace>MyHook</namespace>

	<entity name="Book" local-service="true" remote-service="false">
		<column name="messageId" type="long" primary="true" />

		<column name="title" type="String" />
		<column name="description" type="String" />
		<column name="createdBy" type="long" />
		<column name="createdDate" type="Date" />
		<column name="modifiedBy" type="long" />
		<column name="modifiedDate" type="Date" />

	</entity>

</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
thumbnail
David H Nebinger, módosítva 10 év-val korábban

RE: Unable to add new method in XXXPersistenceImpl class

Liferay Legend Bejegyzések: 14916 Csatlakozás dátuma: 2006.09.02. Legújabb bejegyzések
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.
thumbnail
Mika Koivisto, módosítva 10 év-val korábban

RE: Unable to add new method in XXXPersistenceImpl class

Liferay Legend Bejegyzések: 1519 Csatlakozás dátuma: 2006.08.07. Legújabb bejegyzések
You can create XXXFinderImpl where you add your custom finders that are more complex than what SB can autogenerate from service.xml.
Sunil Kulkarni, módosítva 10 év-val korábban

RE: Unable to add new method in XXXPersistenceImpl class

Junior Member Bejegyzések: 94 Csatlakozás dátuma: 2011.06.24. Legújabb bejegyzések
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.
thumbnail
David H Nebinger, módosítva 10 év-val korábban

RE: Unable to add new method in XXXPersistenceImpl class

Liferay Legend Bejegyzések: 14916 Csatlakozás dátuma: 2006.09.02. Legújabb bejegyzések
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.
thumbnail
Alain Dresse, módosítva 10 év-val korábban

RE: Unable to add new method in XXXPersistenceImpl class

Junior Member Bejegyzések: 95 Csatlakozás dátuma: 2011.07.18. Legújabb bejegyzések
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.