Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JPQL Templates doesn't identify the JPA Provider #440

Closed
panga opened this issue Jun 13, 2013 · 6 comments
Closed

JPQL Templates doesn't identify the JPA Provider #440

panga opened this issue Jun 13, 2013 · 6 comments
Milestone

Comments

@panga
Copy link
Contributor

@panga panga commented Jun 13, 2013

I have a problem with the following code new JPAQuery(em) on JBoss EAP 6.1.0 Final (JBoss AS 7.2.0 Final) + EclipseLink 2.5.0.

The code returns JPQLTemplates.DEFAULT instead of EclipseLinkTemplates.DEFAULT.

The cause is located at method getTemplates of class com.mysema.query.jpa.impl.JPAProvider:

...
public static JPQLTemplates getTemplates(EntityManager em) {
    for (Map.Entry<Class<?>, JPQLTemplates> entry : mappings.entrySet()) {
        if (entry.getKey().isAssignableFrom(em.getDelegate().getClass())) {
            return entry.getValue();
        }
    }
    return JPQLTemplates.DEFAULT;
}
...

I don't know why, but after a debbuging I found that em.getDelegate().getClass() returns a Weld proxy class, that isn't instance of or assignable from org.eclipse.persistence.jpa.JpaEntityManager.

Log output:

08:57:18,033 INFO  [stdout] (http-localhost/127.0.0.1:8080-1) org.eclipse.persistence.jpa.JpaEntityManager is instance of org.jboss.weld.proxies.EntityManager$928554763$Proxy$_$$_WeldClientProxy ? false
08:57:18,033 INFO  [stdout] (http-localhost/127.0.0.1:8080-1) org.eclipse.persistence.jpa.JpaEntityManager is assignable from org.jboss.weld.proxies.EntityManager$928554763$Proxy$_$$_WeldClientProxy ? false
08:57:18,033 INFO  [stdout] (http-localhost/127.0.0.1:8080-1) getTemplates = com.mysema.query.jpa.JPQLTemplates
@timowest
Copy link
Member

@timowest timowest commented Jun 13, 2013

Does the proxy implement any EclipseLink interfaces? What other mechanisms could be used to detect the JPA provider type correctly?

@panga
Copy link
Contributor Author

@panga panga commented Jun 13, 2013

I don't know Weld internals well and also didn't found another good way to identify the JPA provider, actually I'm using as workaround the template parameter.

new JPAQuery(em, EclipseLinkTemplates.DEFAULT)

timowest added a commit that referenced this issue Jul 7, 2013
@timowest
Copy link
Member

@timowest timowest commented Jul 7, 2013

The JPA provider should work better now, since it takes now also the properties of the EntityManagerFactory into account as a fallback.

Could you please try again with the latest SNAPSHOT from here https://oss.sonatype.org/content/repositories/snapshots/

@panga
Copy link
Contributor Author

@panga panga commented Jul 8, 2013

It worked like a charm. Thank you!

@panga panga closed this Jul 8, 2013
@timowest
Copy link
Member

@timowest timowest commented Jul 8, 2013

Good. I'll close it, when it's released

@timowest timowest reopened this Jul 8, 2013
@timowest
Copy link
Member

@timowest timowest commented Jul 29, 2013

Released in 3.2.2

@timowest timowest closed this Jul 29, 2013
@timowest timowest added this to the 3.2.2 milestone Apr 14, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants