Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [Teneo] combining a @ManyToMany and a @OneToMany between 2 entities, how to?
[Teneo] combining a @ManyToMany and a @OneToMany between 2 entities, how to? [message #765581] Wed, 14 December 2011 10:28 Go to next message
David Wynter is currently offline David WynterFriend
Messages: 4624
Registered: July 2009
Senior Member
Hi,

I have a User entity and a Search entity. These have 2 relationships A
User can share many searches and a Search can be shared by many users,
that is the @ManyToMany. A User can own many Searches and a Search can
only be owned by a single user.

We have tried many combinations. We need a getter both side of the User
owned Search association.

<xsd:complexType name="Search">
<xsd:sequence minOccurs="0" maxOccurs="1">
<xsd:element minOccurs="0" maxOccurs="1" type="xsd:anyURI"
ecore:opposite="userOwnedSearch" name="searchOwner"
ecore:reference="secmsec:User">
<xsd:annotation>
<xsd:appinfo source="teneo.jpa"> @ManyToOne
@JoinColumn(name="searchowner", referencedColumnName="id")</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element minOccurs="0" maxOccurs="unbounded"
type="xsd:anyURI" ecore:opposite="userSearch" name="searchUser"
ecore:reference="secmsec:User">
<xsd:annotation>
<xsd:appinfo source="teneo.jpa"> @ManyToMany(indexed=false)
@JoinTable(name="UserSearch")</xsd:appinfo>
</xsd:annotation>
</xsd:element>
....

And

<xsd:complexType name="User">
<xsd:sequence minOccurs="0" maxOccurs="1">
<xsd:element minOccurs="0" maxOccurs="unbounded"
type="xsd:anyURI" ecore:opposite="searchUser" name="userSearch"
ecore:reference="secmsec:Search">
<xsd:annotation>
<xsd:appinfo source="teneo.jpa"> @ManyToMany(indexed=false)
@JoinTable(name="UserSearch")</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element minOccurs="0" maxOccurs="unbounded"
type="xsd:anyURI" ecore:opposite="searchOwner" name="userOwnedSearch"
ecore:reference="secmsec:Search">
<xsd:annotation>
<xsd:appinfo source="teneo.jpa"> @OneToMany(indexed=false)
@JoinColumn(name="id", referencedColumnName="searchowner")</xsd:appinfo>
</xsd:annotation>
</xsd:element>

This give us the getters we need but an extra PK-FK between
User.id-<Search.id? We have the desired and expected
User.id-<Search.searchowner. What is wrong here?

Thx.

David
Re: [Teneo] combining a @ManyToMany and a @OneToMany between 2 entities, how to? [message #765601 is a reply to message #765581] Wed, 14 December 2011 11:09 Go to previous messageGo to next message
David Wynter is currently offline David WynterFriend
Messages: 4624
Registered: July 2009
Senior Member
Hi,

Seems those @JoinColumn referencedColumnName annotations do not work as
we expected, we tried this:

<xsd:element minOccurs="0" maxOccurs="1" type="xsd:anyURI"
ecore:opposite="userOwnedSearch" name="searchOwner"
ecore:reference="secmsec:User">
<xsd:annotation>
<xsd:appinfo source="teneo.jpa"> @ManyToOne
@JoinColumn(name="searchowner")</xsd:appinfo>
</xsd:annotation>
</xsd:element>

and similar for the other end and it now works as expected.

Thx.

David

On 14/12/11 10:28, David Wynter wrote:
> Hi,
>
> I have a User entity and a Search entity. These have 2 relationships A
> User can share many searches and a Search can be shared by many users,
> that is the @ManyToMany. A User can own many Searches and a Search can
> only be owned by a single user.
>
> We have tried many combinations. We need a getter both side of the User
> owned Search association.
>
> <xsd:complexType name="Search">
> <xsd:sequence minOccurs="0" maxOccurs="1">
> <xsd:element minOccurs="0" maxOccurs="1" type="xsd:anyURI"
> ecore:opposite="userOwnedSearch" name="searchOwner"
> ecore:reference="secmsec:User">
> <xsd:annotation>
> <xsd:appinfo source="teneo.jpa"> @ManyToOne
> @JoinColumn(name="searchowner", referencedColumnName="id")</xsd:appinfo>
> </xsd:annotation>
> </xsd:element>
> <xsd:element minOccurs="0" maxOccurs="unbounded" type="xsd:anyURI"
> ecore:opposite="userSearch" name="searchUser"
> ecore:reference="secmsec:User">
> <xsd:annotation>
> <xsd:appinfo source="teneo.jpa"> @ManyToMany(indexed=false)
> @JoinTable(name="UserSearch")</xsd:appinfo>
> </xsd:annotation>
> </xsd:element>
> ...
>
> And
>
> <xsd:complexType name="User">
> <xsd:sequence minOccurs="0" maxOccurs="1">
> <xsd:element minOccurs="0" maxOccurs="unbounded" type="xsd:anyURI"
> ecore:opposite="searchUser" name="userSearch"
> ecore:reference="secmsec:Search">
> <xsd:annotation>
> <xsd:appinfo source="teneo.jpa"> @ManyToMany(indexed=false)
> @JoinTable(name="UserSearch")</xsd:appinfo>
> </xsd:annotation>
> </xsd:element>
> <xsd:element minOccurs="0" maxOccurs="unbounded" type="xsd:anyURI"
> ecore:opposite="searchOwner" name="userOwnedSearch"
> ecore:reference="secmsec:Search">
> <xsd:annotation>
> <xsd:appinfo source="teneo.jpa"> @OneToMany(indexed=false)
> @JoinColumn(name="id", referencedColumnName="searchowner")</xsd:appinfo>
> </xsd:annotation>
> </xsd:element>
>
> This give us the getters we need but an extra PK-FK between
> User.id-<Search.id? We have the desired and expected
> User.id-<Search.searchowner. What is wrong here?
>
> Thx.
>
> David
Re: [Teneo] combining a @ManyToMany and a @OneToMany between 2 entities, how to? [message #765619 is a reply to message #765601] Wed, 14 December 2011 11:47 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi David,
What is the relevant hbm snippet generated for both examples?

gr. Martin

On 12/14/2011 12:09 PM, David Wynter wrote:
> Hi,
>
> Seems those @JoinColumn referencedColumnName annotations do not work as we expected, we tried this:
>
> <xsd:element minOccurs="0" maxOccurs="1" type="xsd:anyURI" ecore:opposite="userOwnedSearch" name="searchOwner"
> ecore:reference="secmsec:User">
> <xsd:annotation>
> <xsd:appinfo source="teneo.jpa"> @ManyToOne @JoinColumn(name="searchowner")</xsd:appinfo>
> </xsd:annotation>
> </xsd:element>
>
> and similar for the other end and it now works as expected.
>
> Thx.
>
> David
>
> On 14/12/11 10:28, David Wynter wrote:
>> Hi,
>>
>> I have a User entity and a Search entity. These have 2 relationships A
>> User can share many searches and a Search can be shared by many users,
>> that is the @ManyToMany. A User can own many Searches and a Search can
>> only be owned by a single user.
>>
>> We have tried many combinations. We need a getter both side of the User
>> owned Search association.
>>
>> <xsd:complexType name="Search">
>> <xsd:sequence minOccurs="0" maxOccurs="1">
>> <xsd:element minOccurs="0" maxOccurs="1" type="xsd:anyURI"
>> ecore:opposite="userOwnedSearch" name="searchOwner"
>> ecore:reference="secmsec:User">
>> <xsd:annotation>
>> <xsd:appinfo source="teneo.jpa"> @ManyToOne
>> @JoinColumn(name="searchowner", referencedColumnName="id")</xsd:appinfo>
>> </xsd:annotation>
>> </xsd:element>
>> <xsd:element minOccurs="0" maxOccurs="unbounded" type="xsd:anyURI"
>> ecore:opposite="userSearch" name="searchUser"
>> ecore:reference="secmsec:User">
>> <xsd:annotation>
>> <xsd:appinfo source="teneo.jpa"> @ManyToMany(indexed=false)
>> @JoinTable(name="UserSearch")</xsd:appinfo>
>> </xsd:annotation>
>> </xsd:element>
>> ...
>>
>> And
>>
>> <xsd:complexType name="User">
>> <xsd:sequence minOccurs="0" maxOccurs="1">
>> <xsd:element minOccurs="0" maxOccurs="unbounded" type="xsd:anyURI"
>> ecore:opposite="searchUser" name="userSearch"
>> ecore:reference="secmsec:Search">
>> <xsd:annotation>
>> <xsd:appinfo source="teneo.jpa"> @ManyToMany(indexed=false)
>> @JoinTable(name="UserSearch")</xsd:appinfo>
>> </xsd:annotation>
>> </xsd:element>
>> <xsd:element minOccurs="0" maxOccurs="unbounded" type="xsd:anyURI"
>> ecore:opposite="searchOwner" name="userOwnedSearch"
>> ecore:reference="secmsec:Search">
>> <xsd:annotation>
>> <xsd:appinfo source="teneo.jpa"> @OneToMany(indexed=false)
>> @JoinColumn(name="id", referencedColumnName="searchowner")</xsd:appinfo>
>> </xsd:annotation>
>> </xsd:element>
>>
>> This give us the getters we need but an extra PK-FK between
>> User.id-<Search.id? We have the desired and expected
>> User.id-<Search.searchowner. What is wrong here?
>>
>> Thx.
>>
>> David
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Previous Topic:[Teneo] How to have non-indexed n:m relations with named join-columns
Next Topic:emf4gwt seems to generate source with problems
Goto Forum:
  


Current Time: Sat Apr 27 05:02:42 GMT 2024

Powered by FUDForum. Page generated in 0.02841 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top