Community
Participate
Working Groups
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5 (.NET CLR 3.5.30729) Build Identifier: N/A This is a request for enhancement, but not a bug report. I did a small N:M master-detail test using TopLink and noticed that the SQL SELECT issued to get the referenced detail (M) entities unnecessarily does a self-JOIN: SELECT t1.vid_qmerkmal, t1.id_nest, t1.vid_auftrag FROM t_atmk t0, t_atmk t1 WHERE ((t0.vid_auftrag = ?) AND ((t1.vid_auftrag = t0.vid_auftrag) AND ((t1.id_nest = t0.id_nest) AND (t1.vid_qmerkmal = t0.vid_qmerkmal)))) As you can see, it does a FROM X, X which just makes things more complex but brings no benefit. Since obviously a an unnecessary JOIN (even an unnecessary self-JOIN) in virtually all cases needs more time to get resolved than a plain "FROM Table", the unnecessary JOIN should get removed in favour of a simple SELECT x FROM Table WHERE ... Reproducible: Always Steps to Reproduce: Maybe only happens when using @EmbeddedId with compound key in the detail (M) entity?
Can't see why EclipseLink would generate that SQL, unless incorrectly mapped or an odd query. Refer to any of the examples or tests that define m-m that do not generate this. Please include your mappings and JPQL query code to get the SQL.
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink