掲示板

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

thumbnail
11年前 に Gnaniyar Zubair によって更新されました。

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

Liferay Master 投稿: 722 参加年月日: 07/12/19 最新の投稿
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
11年前 に David H Nebinger によって更新されました。

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

Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
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
11年前 に Gnaniyar Zubair によって更新されました。

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

Liferay Master 投稿: 722 参加年月日: 07/12/19 最新の投稿
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
11年前 に David H Nebinger によって更新されました。

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

Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
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
10年前 に Riccardo Rotondo によって更新されました。

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

Junior Member 投稿: 29 参加年月日: 10/06/11 最新の投稿
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
10年前 に David H Nebinger によって更新されました。

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

Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
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...
7年前 に Madasamy P によって更新されました。

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

Junior Member 投稿: 90 参加年月日: 16/07/27 最新の投稿
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
7年前 に David H Nebinger によって更新されました。

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

Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
What was the error?






Come meet me at the NAS!