Foren

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

thumbnail
Gnaniyar Zubair, geändert vor 11 Jahren.

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

Liferay Master Beiträge: 722 Beitrittsdatum: 19.12.07 Neueste Beiträge
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, geändert vor 11 Jahren.

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

Liferay Legend Beiträge: 14919 Beitrittsdatum: 02.09.06 Neueste Beiträge
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, geändert vor 11 Jahren.

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

Liferay Master Beiträge: 722 Beitrittsdatum: 19.12.07 Neueste Beiträge
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, geändert vor 11 Jahren.

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

Liferay Legend Beiträge: 14919 Beitrittsdatum: 02.09.06 Neueste Beiträge
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, geändert vor 10 Jahren.

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

Junior Member Beiträge: 29 Beitrittsdatum: 11.06.10 Neueste Beiträge
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, geändert vor 10 Jahren.

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

Liferay Legend Beiträge: 14919 Beitrittsdatum: 02.09.06 Neueste Beiträge
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, geändert vor 7 Jahren.

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

Junior Member Beiträge: 90 Beitrittsdatum: 27.07.16 Neueste Beiträge
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
thumbnail
David H Nebinger, geändert vor 7 Jahren.

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

Liferay Legend Beiträge: 14919 Beitrittsdatum: 02.09.06 Neueste Beiträge
What was the error?






Come meet me at the NAS!