Forums de discussion

Entity Relationship for One-to-Many and Many-to-Many

thumbnail
Gnaniyar Zubair, modifié il y a 11 années.

Entity Relationship for One-to-Many and Many-to-Many

Liferay Master Publications: 722 Date d'inscription: 19/12/07 Publications récentes
Is there any fix available for one to Many or Many to Many issues for Liferay 6.1 GA2. ?

Liferay service builder 6.0.0 DTD file is clearly mentioned like this :

If the entity and mapping-key attributes are specified and mapping-table is not,
then the Service Builder will assume you are specifying a one to many
relationship.

For example:

<column
name="shoppingItemPrices"
type="Collection"
entity="ShoppingItemPrice"
mapping-key="itemId"
/>


But It throws the exception when we try to give the relationship with two entities in service.xml as below:

<column name="bookId" type="Collections" entity="Book" mapping-key="bookId" />
<column name="bookId" type="Collections" entity="Book" mapping-table="library_book" />



Any clarification from community / liferay team?

Thanks in advance

- Gnaniyar Zubair
thumbnail
David H Nebinger, modifié il y a 11 années.

RE: Entity Relationship for One-to-Many and Many-to-Many

Liferay Legend Publications: 14919 Date d'inscription: 02/09/06 Publications récentes
One to many is partially supported (although not completely), and many to many is not supported at all.

Your best path in Service Builder is to stick w/ simple entities and manage the relationships yourself.
thumbnail
Gnaniyar Zubair, modifié il y a 11 années.

RE: Entity Relationship for One-to-Many and Many-to-Many

Liferay Master Publications: 722 Date d'inscription: 19/12/07 Publications récentes
Thanks David.

About Many-to-Many in DTD file:

If the entity and mapping-table attributes are specified and mapping-key is not,
then the Service Builder will assume you are specifying a many to many
relationship.

For example:

<column
name="roles"
type="Collection"
entity="Role"
mapping-table="Groups_Roles"
/>


Are you telling to manage everything through finder methods..?
thumbnail
David H Nebinger, modifié il y a 11 années.

RE: Entity Relationship for One-to-Many and Many-to-Many

Liferay Legend Publications: 14919 Date d'inscription: 02/09/06 Publications récentes
You can define them in the service.xml file, but the generated interfaces will not have the collections in them for CRUD activitities.

So yes, you end up having to manage relationships on your own...
thumbnail
Riccardo Rotondo, modifié il y a 10 années.

RE: Entity Relationship for One-to-Many and Many-to-Many

Junior Member Publications: 29 Date d'inscription: 11/06/10 Publications récentes
Dear All,

I have a different problem. I'd like to make a many-to-many relation between fields of the same entity. Is there any way to do that?

Thank you for your help.

Regards,

Riccardo
thumbnail
David H Nebinger, modifié il y a 10 années.

RE: Entity Relationship for One-to-Many and Many-to-Many

Liferay Legend Publications: 14919 Date d'inscription: 02/09/06 Publications récentes
um, i think that violates the whole relational data model, unless you're talking about creating finders to return a list of entities that match a search criteria or something...
Madasamy P, modifié il y a 7 années.

RE: Entity Relationship for One-to-Many and Many-to-Many

Junior Member Publications: 90 Date d'inscription: 27/07/16 Publications récentes
Hi,
I'm using two entities as LMBook and LMBorrwing
Here I gonna mapping as one to many relationship as below:

<column
name="lmBorrowings"
type="Collection"
entity="LMBorrowing"
mapping-table="Books_LMBook" />

But It produces an error in LMBookPersistence and LMBookLocalServiceBaseImpl

What is the way to resolve my error and How to define the mapping attribute in the field

Pièces jointes:

thumbnail
David H Nebinger, modifié il y a 7 années.

RE: Entity Relationship for One-to-Many and Many-to-Many

Liferay Legend Publications: 14919 Date d'inscription: 02/09/06 Publications récentes
What was the error?






Come meet me at the NAS!