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

Comments

Projects
None yet
2 participants
@panga
Contributor

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

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Jun 13, 2013

Member

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

Member

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

This comment has been minimized.

Show comment
Hide comment
@panga

panga Jun 13, 2013

Contributor

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)

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Jul 7, 2013

Member

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/

Member

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

This comment has been minimized.

Show comment
Hide comment
@panga

panga Jul 8, 2013

Contributor

It worked like a charm. Thank you!

Contributor

panga commented Jul 8, 2013

It worked like a charm. Thank you!

@panga panga closed this Jul 8, 2013

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Jul 8, 2013

Member

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

Member

timowest commented Jul 8, 2013

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

@timowest timowest reopened this Jul 8, 2013

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Jul 29, 2013

Member

Released in 3.2.2

Member

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