Tobias - Hmm, I thought for sure that this worked.... but I stand corrected. You are correc that when selecting an Entity that is the owner of a bidirectional, eager 1-1 (perhaps others) we issue an extra join. You probably already found this out.... but if you were to call em.find(B.class, [id]), we do issue the correct SQL.
Unfortunately, I don't have a very good solution for you at this time... You could mark A->B as lazy and every time you call em.find(A.class, [id]), you could reference the B field. I'm not sure if this would be better or worse than the extra join. Thanks, Rick On Tue, Oct 18, 2011 at 9:32 AM, Tobias Trelle <tobias.tre...@codecentric.de > wrote: > > Rick Curtis wrote: > > > > Sorry I didn't ask this in my initial email.... what version of OpenJPA > > are > > you using, and how are you enhancing your Entities? > > > > I'm using OpenJPA 2.0.1. > > The double join happens both with runtime and build time enhanced classes. > The build time enhancement is done with an ant task: > > openjpa-enhance: > [openjpac] INFO 16:29:51 - No targets were given. Running on all classes > in your persistent classes list, or all metadata files in classpath > directories if you have not listed your persistent classes. Use -help to > display tool usage information. > [openjpac] TRACE 16:29:51 - Enhancer running on type > "com.xyz.framework.util.db.jpa.oto.A". > [openjpac] TRACE 16:29:52 - Enhancer running on type > "com.xyz.framework.util.db.jpa.oto.B". > BUILD SUCCESSFUL > Total time: 2 seconds > > Cheers, > Tobias > > > -- > -- *Rick Curtis*