Reputation: 732
I have a question relating to the Liferay Service Builder. I want to create a many-to-many relationship with custom colums in the created Join table.
This is my service.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 6.2.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_6_2_0.dtd">
<service-builder package-path="de.mycompany.mm.services">
<author>rawdog</author>
<namespace>mycompany</namespace>
<entity name="Registration" local-service="true" remote-service="false">
<column name="RegID" type="long" primary="true"></column>
<column name="Email" type="String"></column>
<column name="Hash" type="String"></column>
<column name="Validate" type="boolean"></column>
<column name="NewsletterID" type="Collection" entity="Newsletter" mapping-table="Registration_Newsletter"/>
<finder name="Hash" return-type="Registration">
<finder-column name="Hash"></finder-column>
</finder>
</entity>
<entity name="Newsletter" local-service="true" remote-service="false">
<column name="NewsletterID" type="long" primary="true"></column>
<column name="Name" type="String"></column>
<column name="Status" type="boolean"></column>
<column name="RegID" type="Collection" entity="Registration" mapping-table="Registration_Newsletter"/>
</entity>
</service-builder>
This automatically creates following SQL CREATE statement:
create table mycompany_Registration_Newsletter (
RegID LONG not null,
NewsletterID LONG not null,
primary key (ANID, MMID)
);
How could I also automatically create custom colums in the JOIN table like Status BOOLEAN. It should look like this in the end:
create table mycompany_Registration_Newsletter (
RegID LONG not null,
NewsletterID LONG not null,
Status BOOLEAN,
primary key (ANID, MMID)
);
Thanks for any help.
Upvotes: 2
Views: 785
Reputation: 11
You have two ways to solve this problem :
ALTER TABLE yourJoinedTable ADD yourBooleanColumn BOOLEAN NOT NULL;
) and then define CUSTOM SQL / NATIVE QUERY IN SERVICE BUILDER to use this joined table. Upvotes: 1