|
|
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 |
Martin Taal 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
|
|
|
Powered by
FUDForum. Page generated in 0.02841 seconds