Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [eclipselink-users] customize OneToMany Mapping

Where do the tables T1, and T2 come from, is Posten using multiple tables or
inheritance?  Please include its mappings, they may be wrong.  The m-m join
looks correct.



Robert Wimmer wrote:
> 
> 
> Hi Tom,
> 
>>    For a OneToMany (rather than OneToOne) with a join table, just use a 
>> ManyToMany mapping.  There should be an example of one of those in the
>> example 
>> code I pointed you at earlier.
> 
> as you suggested i tried it with a ManyToManyMapping, but only with some
> success
> 
> my Mapping definition
> ...
> ManyToManyMapping mmm = new ManyToManyMapping();
> mmm.setAttributeName("posten");
> mmm.setReferenceClass(Posten.class);
> mmm.dontUseIndirection();
> mmm.setRelationTableName("wpt_posten_bestellungen_lbez");
> mmm.addSourceRelationKeyFieldName("wpt_posten_bestellungen_lbez.wpt_bestellungen_id","WPT_BESTELLUNGEN.TID");
> mmm.addTargetRelationKeyFieldName("wpt_posten_bestellungen_lbez.wpt_bestellposten_liste_id","WPT_BESTELLPOSTEN_LISTE.TID");
> wptBestellungenDescriptor.addMapping(mmm);
> ...
> 
> the problem is it only returns 1 row instead of multiple rows
> 
> to make it clearer some sql
> 
> -- the "handmade" query 
> SELECT liste.tid,liste.eintrag FROM wpt_bestellposten_liste liste
> JOIN wpt_posten_bestellungen_lbez lbez  ON lbez.wpt_bestellposten_liste_id
> = liste.tid
> JOIN wpt_bestellungen b ON lbez.wpt_bestellungen_id = b.tid
> WHERE b.tid = 119.9; 
> -- returns 5 records (es expected)
> 
> -- eclipselink generated query
> SELECT t1.TID, t2.TID, t1.EINTRAG FROM 
>        wpt_posten_bestellungen_lbez t0, 
>        WPT_BESTELLUNGEN t2, 
>        WPT_BESTELLPOSTEN_LISTE t1 
> WHERE (((t0.wpt_bestellungen_id = 119.9) 
>       AND (t1.TID = t0.wpt_bestellposten_liste_id)) 
>       AND (t2.TID = t1.TID)
>       );
> -- returns only 1 record
> 
> -- the query eclipselink should generate
> SELECT t1.TID, t2.TID, t1.EINTRAG FROM 
>        wpt_posten_bestellungen_lbez t0, 
>        WPT_BESTELLUNGEN t2, 
>        WPT_BESTELLPOSTEN_LISTE t1 
> WHERE (((t0.wpt_bestellungen_id = 119.9) 
>       AND (t1.TID = t0.wpt_bestellposten_liste_id)) 
>       AND (t2.TID = t0.wpt_bestellungen_id)  -- <<< t2.TID != t1.TID   
>       );
> 
> as you see the second AND expression is parameterized not as expected. 
> I tried to rewrite the mapping in a lot of different ways, but never got
> the expected result. 
> 
>>Before JPA, the typical way to use EclipseLink (then called TopLink) was
to
>>use the MappingWorkbench to describe your metadata and export either Java
code
>>or an XML document that contains that metadata.  I realize that will not
get you
>>all the way to your goal.  If you use the facility to export java code, it
will,
>>however give you a way to generate and see the type of java code that
>>EclipseLink expects for its descriptors and mappings - a way to
prototype.where can I download this workbench ?
> 
> One main reason for not using JPA is, that i am not able to get it running
> in a simple RCP application (without any Application-Server). I found some
> links describing solutions for this problems but I am not able to develop
> sample applications with our own background. This is a lot easier using
> the "native" eclipse-link api. 
> 
> regards 
> 
> Sepp
> 
> 
> _________________________________________________________________
> Hol dir 30 kostenlose Emoticons für deinen Windows Live Messenger
> http://www.livemessenger-emoticons.com/funfamily/de-at/
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
> 
> 


-----
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland 
http://www.eclipse.org/eclipselink/
 EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink 
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink , 
http://wiki.oracle.com/page/TopLink TopLink 
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink , 
http://www.nabble.com/EclipseLink-f26430.html EclipseLink 
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence 
-- 
View this message in context: http://www.nabble.com/customize-OneToMany-Mapping-tp24568733p24701765.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top