Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Join condition of INNER JOIN
Join condition of INNER JOIN [message #1779329] Fri, 05 January 2018 13:26 Go to next message
Frederick Gaens is currently offline Frederick GaensFriend
Messages: 3
Registered: January 2018
Junior Member
I recently got a question from our DBA who wanted me to rewrite a query with an INNER JOIN so that the join condition would be in the FROM clause.

Because the JPQL query was already OK, I started looking through the Eclipselink documentation and came across this:
For INNER joins EclipseLink will normally append the join condition to the WHERE clause, but this can be configured in the DatabasePlatform.

Is there any way to force Eclipselink to generate a query where the join condition of an inner join will be in the from clause?
Re: Join condition of INNER JOIN [message #1779496 is a reply to message #1779329] Mon, 08 January 2018 17:32 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
https://bugs.eclipse.org/bugs/show_bug.cgi?id=246356 shows how to enable the join to be put in the from clause in EclipseLink 2.4; this same method should be able to turn off this behaviour so that joins are done in the where clause for all queries by default. You will need to call platform.setPrintInnerJoinInWhereClause(true); within a session customizer event as described here https://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Advanced_JPA_Development/Customizers where you use the session to get the databasePlatform set through your configuration, or change it to a custom implementation.

Best Regards,
Chris
Re: Join condition of INNER JOIN [message #1781420 is a reply to message #1779496] Wed, 07 February 2018 08:06 Go to previous messageGo to next message
Frederick Gaens is currently offline Frederick GaensFriend
Messages: 3
Registered: January 2018
Junior Member
So I created a session customizer
package be.dkv.evvplus.configuration.eclipselink;

import org.eclipse.persistence.config.SessionCustomizer;
import org.eclipse.persistence.sessions.Session;

public class EclipseLinkSessionCustomizer implements SessionCustomizer {
    @Override
    public void customize(Session session) throws Exception {
        session.getPlatform().setPrintInnerJoinInWhereClause(false);
    }
}


and I added it to the persistence.xml
<property name="eclipselink.session.customizer" value="be.dkv.evvplus.configuration.eclipselink.EclipseLinkSessionCustomizer" />


When I try to deploy it on GlassFish, I'm getting the following error:
java.lang.NoSuchMethodError: org.eclipse.persistence.platform.database.DatabasePlatform.setPrintInnerJoinInWhereClause(Z)V
	at be.dkv.evvplus.configuration.eclipselink.EclipseLinkSessionCustomizer.customize(EclipseLinkSessionCustomizer.java:9)
	at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.processSessionCustomizer(EntityManagerSetupImpl.java:1985)
	at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.updateSession(EntityManagerSetupImpl.java:1953)
	at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:471)
	at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getDatabaseSession(EntityManagerFactoryDelegate.java:188)
	at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.createEntityManagerImpl(EntityManagerFactoryDelegate.java:277)
	at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:294)
	at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:272)
	at org.glassfish.persistence.jpa.PersistenceUnitLoader.loadPU(PersistenceUnitLoader.java:211)
	at org.glassfish.persistence.jpa.PersistenceUnitLoader.<init>(PersistenceUnitLoader.java:120)
	at org.glassfish.persistence.jpa.JPADeployer$1.visitPUD(JPADeployer.java:224)
	at org.glassfish.persistence.jpa.JPADeployer$PersistenceUnitDescriptorIterator.iteratePUDs(JPADeployer.java:495)
	at org.glassfish.persistence.jpa.JPADeployer.createEMFs(JPADeployer.java:233)
	at org.glassfish.persistence.jpa.JPADeployer.prepare(JPADeployer.java:168)
	at com.sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.java:871)
	at org.glassfish.javaee.full.deployment.EarDeployer.prepareBundle(EarDeployer.java:290)
	at org.glassfish.javaee.full.deployment.EarDeployer.access$200(EarDeployer.java:86)
	at org.glassfish.javaee.full.deployment.EarDeployer$1.doBundle(EarDeployer.java:141)
	at org.glassfish.javaee.full.deployment.EarDeployer$1.doBundle(EarDeployer.java:138)
	at org.glassfish.javaee.full.deployment.EarDeployer.doOnBundles(EarDeployer.java:215)
	at org.glassfish.javaee.full.deployment.EarDeployer.doOnAllTypedBundles(EarDeployer.java:224)
	at org.glassfish.javaee.full.deployment.EarDeployer.doOnAllBundles(EarDeployer.java:250)
	at org.glassfish.javaee.full.deployment.EarDeployer.prepare(EarDeployer.java:138)
	at com.sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.java:871)
	at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:410)
	at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
	at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:389)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:348)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:363)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1066)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:95)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1291)
	at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1259)
	at org.glassfish.admin.rest.ResourceUtil.runCommand(ResourceUtil.java:214)
	at org.glassfish.admin.rest.ResourceUtil.runCommand(ResourceUtil.java:207)
	at org.glassfish.admin.rest.resources.TemplateListOfResource.createResource(TemplateListOfResource.java:148)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
	at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205)
	at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
	at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:288)
	at com.sun.jersey.server.impl.uri.rules.SubLocatorRule.accept(SubLocatorRule.java:134)
	at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
	at com.sun.jersey.server.impl.uri.rules.SubLocatorRule.accept(SubLocatorRule.java:134)
	at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
	at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
	at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
	at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
	at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1469)
	at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1400)
	at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1349)
	at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1339)
	at com.sun.jersey.server.impl.container.grizzly.GrizzlyContainer._service(GrizzlyContainer.java:182)
	at com.sun.jersey.server.impl.container.grizzly.GrizzlyContainer.service(GrizzlyContainer.java:147)
	at org.glassfish.admin.rest.adapter.RestAdapter.service(RestAdapter.java:148)
	at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:179)
	at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
	at com.sun.enterprise.v3.services.impl.ContainerMapper$Hk2DispatcherCallable.call(ContainerMapper.java:354)
	at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
	at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
	at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
	at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
	at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
	at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
	at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
	at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
	at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
	at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
	at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
	at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
	at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
	at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
	at java.lang.Thread.run(Thread.java:745)

Re: Join condition of INNER JOIN [message #1781724 is a reply to message #1781420] Mon, 12 February 2018 15:02 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
I'd guess this is due to an issue with the version you compiled against not being the same as the version you are running against.
Re: Join condition of INNER JOIN [message #1835451 is a reply to message #1779329] Thu, 03 December 2020 15:59 Go to previous messageGo to next message
Thomas Giger is currently offline Thomas GigerFriend
Messages: 3
Registered: August 2015
Junior Member
If I have a look at https://bugs.eclipse.org/bugs/show_bug.cgi?id=246356 it looks like the development of the feature is not completely finished. I see that there are issues with some or our more complex queries when we use the feature to print JOINs into the FROM clause. Is there a possibility to achieve the same per query?
Re: Join condition of INNER JOIN [message #1850082 is a reply to message #1835451] Tue, 15 February 2022 08:07 Go to previous message
Thomas Giger is currently offline Thomas GigerFriend
Messages: 3
Registered: August 2015
Junior Member
I am still struggling with some queries that are slow, likely caused by joining in the where clause instead of the from clause. Since I cannot use the feature globally (for instance IS EMPTY seems to fail), is there a way to use this feature for one single query?
Previous Topic:Migrating EclipseLink from 2.7.x to 3.0.2
Next Topic:EclipseLink fails with to connect to DB
Goto Forum:
  


Current Time: Fri Apr 19 07:13:01 GMT 2024

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

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

Back to the top