掲示板

fake entity in liferay

thumbnail
8年前 に Tahir Noor Khaliq によって更新されました。

fake entity in liferay

Junior Member 投稿: 35 参加年月日: 15/02/05 最新の投稿
can v use composition with fake entity?
thumbnail
8年前 に Olaf Kock によって更新されました。

RE: fake entity in liferay

Liferay Legend 投稿: 6403 参加年月日: 08/09/23 最新の投稿
...to solve which problem? IMHO this is easier to discuss when knowing what you want to achieve. Neither a "yes" nor a "no" would help you tremendously, right?
thumbnail
8年前 に Tahir Noor Khaliq によって更新されました。

RE: fake entity in liferay

Junior Member 投稿: 35 参加年月日: 15/02/05 最新の投稿
i want to create fake service builder entities without db tables, Entity have one to many mapping, eg Student has address
<entity name="FakeStudent" remote-service="true">
<column name='fakeStudentId' type='long' primary='true'/>
<column name='name' type='String'/>

<column name="address" type="Collection" entity="FakeAddress" mapping-table="FakeAddress_Student"/>

</entity>
<entity name="FakeAddress" remote-service="true">
<column name='fakAddressId' type='long' primary='true'/>
<column name='address' type='String'/>
</entity>

is it possible to use Collections?
thumbnail
8年前 に David H Nebinger によって更新されました。

RE: fake entity in liferay

Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
There's no magic to fake entities. They have the same features and constraints as regular entities. Contained collections within an entity typically give SB problems because there's no easy way to manage crossing the class loader boundary with those, so you'll frequently get the operation not supported exception.
thumbnail
8年前 に Tahir Noor Khaliq によって更新されました。

RE: fake entity in liferay

Junior Member 投稿: 35 参加年月日: 15/02/05 最新の投稿
so how to resolve this problem becoz i need collections within an entity , plzz Help
thumbnail
8年前 に David H Nebinger によって更新されました。

RE: fake entity in liferay

Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
It's a service builder issue.

Common way is to not use the collection embedded in the entity but to add a separate method to retrieve the collection.

So in FakeAddress_StudentLocalServiceImpl, add a "public List<FakeAddress> getStudentAddresses(final long studentId) {}" method and invoke separately. That class would retrieve the values from the join table, then retrieve each student to be returned and add to the list.

Remember, SB is not a full ORM, nor is it meant to be. It is meant to be a service layer than can be accessed by many separate portlets in separate class loaders. If you try to force ORM on your SB layer, you're doomed to fail (just as you are doomed if you try to use a full ORM in place of SB ).
thumbnail
8年前 に Olaf Kock によって更新されました。

RE: fake entity in liferay

Liferay Legend 投稿: 6403 参加年月日: 08/09/23 最新の投稿
If you look at Liferay's services, every service only hands out the entities according to its name. You'd never ask the FakeStudentService for a FakeStudentAddress, rather you'd ask the FakeStudentAddressService for all the addresses, given a FakeStudent or its id. This tremendously eases the problem with cross-context-classloading that David mentioned and that ServiceBuilder solves in a nice way. Just add another service and another entity and you're done
thumbnail
8年前 に Filippo Maria Del Prete によって更新されました。

RE: fake entity in liferay

New Member 投稿: 8 参加年月日: 12/03/08 最新の投稿
This is my fake entity:

In the service.xml file you have:

...
	<entity name="FakeEntity" local-service="true" remote-service="false" data-source="noDataSource">
		<column name="fakeId" type="long" primary="true" />
		<column name="dateInvoice" type="Date" />
		<column name="amount" type="double" />
		<column name="customerName" type="String" />
		<column name="customerCode" type="String" />
		<column name="description" type="String" />
		<column name="consumption" type="double" />
	</entity>


Please note the data-source entity attribute with the "noDataSOurce" value.

Then create your datasource package with the noDataSource class

package it.xxx.yyyy.datasource;

import javax.sql.DataSource;

public class NoDataSource {
	/**
	 * getDataSource: Supposed to return a DataSource.
	 * @return DataSource Always returns null.
	 */
	public static DataSource getDataSource() {
		return null;
	}
}


The Service Builder will do the magic...