Foros de discusión

SQL generated by service builder & relationships

Andy Moora, modificado hace 11 años.

SQL generated by service builder & relationships

New Member Mensajes: 3 Fecha de incorporación: 18/10/12 Mensajes recientes
Hi all,

I'm trying to understand how service builder works. I have my service.xml file


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

<service-builder package-path="com.my.company">

	<author>I</author>
	<namespace>MY</namespace>

	<entity name="One" local-service="true" remote-service="false">
<column name="oneId" type="long" primary="true" />
	</entity>
	<entity name="Two" local-service="true" remote-service="false">
<column name="twoId" type="long" primary="true" />
		<column name="name" type="String" />
		<column name="oneId" type="Collection" entity="One mapping-key=" oneId" />
	</entity>
</service-builder>


and this gave me such sql tables file:


create table MY_One(
	oneId LONG not null primary key
);

create table MY_Two(
	twoId LONG not null primary key,
	name VARCHAR(75) null
);

where is information about relationship in this sql? Is tere some service builder bug or I made some mistake with this one to many relationship?

Liferay 6.1
Ant 1.8.4
liferay-plugins-sdk-6.1.1
Liferay IDE 1.6.0

Edit:

Or maybe it is correct? Can anyone provide working one to many example?
thumbnail
David H Nebinger, modificado hace 11 años.

RE: SQL generated by service builder & relationships

Liferay Legend Mensajes: 14915 Fecha de incorporación: 2/09/06 Mensajes recientes
SB does not handle relationships. You must manually manage the relationships yourself.

For your child entities you can define a finder based upon the parent id to retrieve the list of children for the parent id.
Andy Moora, modificado hace 11 años.

RE: SQL generated by service builder & relationships

New Member Mensajes: 3 Fecha de incorporación: 18/10/12 Mensajes recientes
Can You provide example so I will be sure to make this right?
thumbnail
Hitoshi Ozawa, modificado hace 11 años.

RE: SQL generated by service builder & relationships

Liferay Legend Mensajes: 7942 Fecha de incorporación: 24/03/10 Mensajes recientes
I think you're missing the main point of service builder. I think it's because Brian Chan hasn't explained it too well yet.

Developers are mistaking service builder as a tool to generating database entities. Service builder as the name implies is used to generate "service". "Service" here implies interfaces. "Entities" in service.xml are entities in interface definition.

Service builder, however, also generates "standard" set of database entities by default. However, it's really up to the developer to use these "default" set of database entities or to use some external entities. It's also possible to customize how these database entities are created.

As service builder is about interfaces and interfaces doesn't have relationships, there's no concept of relationship supported by service builder. If you want to add relationship to the "default" database entities, you'll have to do it on your own.

Furthermore, liferay is designed to be a high performance platform. Database entities by "default" doesn't have relationships because they're designed to be transactional database entities instead of applicational or data mining database entities. Remember that liferay can be clustered and entities are cached in each server in a cluster before they are written to a database.
ron rei, modificado hace 11 años.

RE: SQL generated by service builder & relationships

New Member Mensaje: 1 Fecha de incorporación: 4/11/12 Mensajes recientes
Hey guys, thanks for all the input.
But I still don't get it.
In the case above, how do we make the tables so that they
do have the collection inside them?
could someone please post some directions?
Thanks!