UnsupportedOperationException: org.hibernate.jpa.internal.EntityManagerImpl is not supported

已回答

Hi,

My tech stack is as follows: Idea 2016.2.1 Ultimate, JPA 2.0 and Hibernate 5

 

I have a project with JPA Facet and in the Persistence window I can see my persistence unit and also execute queries to it via the QL console.

However for some odd reason I am unable to generate the SQL (Ctrl + Shift + Enter) off the QL, with a one-line error:

 

[2016-08-05 10:40:25] UnsupportedOperationException: org.hibernate.jpa.internal.EntityManagerImpl is not supported

 

I have a suspicion that maybe Hibernate 5 is not yet supported, but I am not so sure because if that is the case then I wouldn't have been able to execute queries to begin with. You can find my persistence.xml content at the bottom of this message

Any help is appreciated. Do let me know if you need any more information.

 

---

 

<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">

<persistence-unit name="epv2-context2">

<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>

<jta-data-source>java:jboss/datasources/ENTROPAYDS</jta-data-source>

<class>com.ixaris.smartpay.antifraud.impl.ejb.entity.fraudscorerecord.FraudScoreRecord</class>
<class>com.ixaris.smartpay.antifraud.impl.ejb.entity.fraudscorerecord.recommendedactionrecord.FraudScoreRecommendedActionRecord</class>
<class>com.ixaris.smartpay.antifraud.impl.ejb.entity.fraudscorerecord.rulecomponentrecord.RuleComponentRecord</class>

<!-- only cache selective entities. Search for @Cacheable or @Cache in
the code. -->
<shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.event.merge.entity_copy_observer"value="allow" />
</properties>
</persistence-unit>
</persistence>

3

>However for some odd reason I am unable to generate the SQL (Ctrl + Shift + Enter) off the QL, with a one-line error:

So you invoke it in QL console?

Please attach latest idea.log content after restart and reproducing the error. Thanks.

0

Hi! I have the same problem generating sql from QL console. However I use JPA 2.1. I reproduced the error :

[2016-11-29 19:10:14] UnsupportedOperationException: org.hibernate.jpa.internal.EntityManagerImpl is not supported


Here is idea's log:


2016-11-29 19:10:08,577 [ 105100] WARN - ution.rmi.RemoteProcessSupport - Nov 29, 2016 7:10:08 PM org.hibernate.ejb.HibernatePersistence logDeprecation
2016-11-29 19:10:08,577 [ 105100] WARN - ution.rmi.RemoteProcessSupport - WARN: HHH015016: Encountered a deprecated javax.persistence.spi.PersistenceProvider [org.hibernate.ejb.HibernatePersistence]; use [org.hibernate.jpa.HibernatePersistenceProvider] instead.
2016-11-29 19:10:08,577 [ 105100] WARN - ution.rmi.RemoteProcessSupport - Nov 29, 2016 7:10:08 PM org.hibernate.ejb.HibernatePersistence logDeprecation
2016-11-29 19:10:08,577 [ 105100] WARN - ution.rmi.RemoteProcessSupport - WARN: HHH015016: Encountered a deprecated javax.persistence.spi.PersistenceProvider [org.hibernate.ejb.HibernatePersistence]; use [org.hibernate.jpa.HibernatePersistenceProvider] instead.
2016-11-29 19:10:08,579 [ 105102] WARN - ution.rmi.RemoteProcessSupport - Nov 29, 2016 7:10:08 PM org.hibernate.ejb.HibernatePersistence logDeprecation
2016-11-29 19:10:08,579 [ 105102] WARN - ution.rmi.RemoteProcessSupport - WARN: HHH015016: Encountered a deprecated javax.persistence.spi.PersistenceProvider [org.hibernate.ejb.HibernatePersistence]; use [org.hibernate.jpa.HibernatePersistenceProvider] instead.
2016-11-29 19:10:08,627 [ 105150] WARN - ution.rmi.RemoteProcessSupport - Nov 29, 2016 7:10:08 PM org.hibernate.jpa.internal.util.LogHelper logPersistenceUnitInformation
2016-11-29 19:10:08,627 [ 105150] WARN - ution.rmi.RemoteProcessSupport - INFO: HHH000204: Processing PersistenceUnitInfo [
2016-11-29 19:10:08,627 [ 105150] WARN - ution.rmi.RemoteProcessSupport - name: myWMS
2016-11-29 19:10:08,627 [ 105150] WARN - ution.rmi.RemoteProcessSupport - ...]
2016-11-29 19:10:08,717 [ 105240] WARN - ution.rmi.RemoteProcessSupport - Nov 29, 2016 7:10:08 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
2016-11-29 19:10:08,717 [ 105240] WARN - ution.rmi.RemoteProcessSupport - WARN: HHH000402: Using Hibernate built-in connection pool (not for production use!)
2016-11-29 19:10:08,724 [ 105247] WARN - ution.rmi.RemoteProcessSupport - Nov 29, 2016 7:10:08 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
2016-11-29 19:10:08,724 [ 105247] WARN - ution.rmi.RemoteProcessSupport - INFO: HHH000401: using driver [org.postgresql.Driver] at URL [jdbc:postgresql://**dbconnection**]
2016-11-29 19:10:08,725 [ 105248] WARN - ution.rmi.RemoteProcessSupport - Nov 29, 2016 7:10:08 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
2016-11-29 19:10:08,725 [ 105248] WARN - ution.rmi.RemoteProcessSupport - INFO: HHH000046: Connection properties: {user=****, password=****}
2016-11-29 19:10:08,725 [ 105248] WARN - ution.rmi.RemoteProcessSupport - Nov 29, 2016 7:10:08 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
2016-11-29 19:10:08,725 [ 105248] WARN - ution.rmi.RemoteProcessSupport - INFO: HHH000006: Autocommit mode: false
2016-11-29 19:10:08,725 [ 105248] WARN - ution.rmi.RemoteProcessSupport - Nov 29, 2016 7:10:08 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
2016-11-29 19:10:08,725 [ 105248] WARN - ution.rmi.RemoteProcessSupport - INFO: HHH000115: Hibernate connection pool size: 20 (min=1)
2016-11-29 19:10:13,414 [ 109937] WARN - ution.rmi.RemoteProcessSupport - Nov 29, 2016 7:10:13 PM org.hibernate.dialect.Dialect <init>
2016-11-29 19:10:13,414 [ 109937] WARN - ution.rmi.RemoteProcessSupport - INFO: HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect
2016-11-29 19:10:13,414 [ 109937] WARN - ution.rmi.RemoteProcessSupport - Nov 29, 2016 7:10:13 PM org.hibernate.engine.jdbc.internal.LobCreatorBuilder useContextualLobCreation
2016-11-29 19:10:13,414 [ 109937] WARN - ution.rmi.RemoteProcessSupport - INFO: HHH000424: Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException
2016-11-29 19:10:13,669 [ 110192] WARN - ution.rmi.RemoteProcessSupport - Nov 29, 2016 7:10:13 PM org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory <init>
2016-11-29 19:10:13,669 [ 110192] WARN - ution.rmi.RemoteProcessSupport - INFO: HHH000397: Using ASTQueryTranslatorFactory
2016-11-29 19:10:14,946 [ 111469] WARN - ution.rmi.RemoteProcessSupport - Nov 29, 2016 7:10:14 PM org.hibernate.jpa.internal.EntityManagerFactoryRegistry addEntityManagerFactory
2016-11-29 19:10:14,946 [ 111469] WARN - ution.rmi.RemoteProcessSupport - WARN: HHH000436: Entity manager factory name (factoryName) is already registered. If entity manager will be clustered or passivated, specify a unique value for property 'hibernate.ejb.entitymanager_factory_name'

1

I'm having the same problem. Did you ever manage to resolve this issue?

0

Any solution for this problem? I am also getting same error for a simple JQL query. I couldn't see SQL statement.

0

l have the same problem in JPA console.

UnsupportedOperationException: org.hibernate.internal.SessionImpl is not supported

on Generate SQL, 

while Execute Query works OK.

idea.log

2017-10-30 21:59:24,552 [ 990056] DEBUG - #com.intellij.execution.rmi.RemoteProcessSupport - "/Users/s.kosarev/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/172.4343.14/IntelliJ IDEA.app/Contents/jdk/Contents/Home/jre/bin/java" -Dcom.jetbrains.jpa.root=/Users/s.kosarev/Library/Caches/IntelliJIdea2017.2/compiler/wmslamoda.daca1a76/.generated/Jpa_Console/jpa-PU-1509389964547 -Dfile.encoding=UTF-8 -classpath "/Users/s.kosarev/Library/Caches/IntelliJIdea2017.2/compiler/wmslamoda.daca1a76/.generated/Jpa_Console/jpa-PU-1509389964547:/Users/s.kosarev/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/172.4343.14/IntelliJ IDEA.app/Contents/lib/util.jar:/Users/s.kosarev/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/172.4343.14/IntelliJ IDEA.app/Contents/lib/trove4j.jar:/Users/s.kosarev/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/172.4343.14/IntelliJ IDEA.app/Contents/lib/groovy-all-2.4.6.jar:/Users/s.kosarev/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/172.4343.14/IntelliJ IDEA.app/Contents/plugins/DatabaseTools/lib/jdbc-console.jar:/Users/s.kosarev/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/172.4343.14/IntelliJ IDEA.app/Contents/plugins/DatabaseTools/lib/dekaf-single-2.0.0.296.jar:/Users/s.kosarev/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/172.4343.14/IntelliJ IDEA.app/Contents/plugins/JavaEE/lib/jpa-console.jar:/Users/s.kosarev/repo/postgresql/postgresql-9.4.1211.jar:/Users/s.kosarev/.m2/repository/org/hibernate/hibernate-core/5.2.12.Final/hibernate-core-5.2.12.Final.jar:/Users/s.kosarev/.m2/repository/org/jboss/logging/jboss-logging/3.3.0.Final/jboss-logging-3.3.0.Final.jar:/Users/s.kosarev/.m2/repository/org/hibernate/javax/persistence/hibernate-jpa-2.1-api/1.0.0.Final/hibernate-jpa-2.1-api-1.0.0.Final.jar:/Users/s.kosarev/.m2/repository/org/javassist/javassist/3.20.0-GA/javassist-3.20.0-GA.jar:/Users/s.kosarev/.m2/repository/antlr/antlr/2.7.7/antlr-2.7.7.jar:/Users/s.kosarev/.m2/repository/org/jboss/spec/javax/transaction/jboss-transaction-api_1.2_spec/1.0.1.Final/jboss-transaction-api_1.2_spec-1.0.1.Final.jar:/Users/s.kosarev/.m2/repository/org/jboss/jandex/2.0.3.Final/jandex-2.0.3.Final.jar:/Users/s.kosarev/.m2/repository/com/fasterxml/classmate/1.3.0/classmate-1.3.0.jar:/Users/s.kosarev/.m2/repository/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar:/Users/s.kosarev/.m2/repository/org/hibernate/common/hibernate-commons-annotations/5.0.1.Final/hibernate-commons-annotations-5.0.1.Final.jar:/Users/s.kosarev/repo/origin/wmslamoda/wms-model/target/classes:/Users/s.kosarev/.m2/repository/com/google/code/findbugs/jsr305/2.0.1/jsr305-2.0.1.jar:/Users/s.kosarev/repo/origin/wmslamoda/tools/fsm/target/classes:/Users/s.kosarev/.m2/repository/com/google/guava/guava/18.0/guava-18.0.jar:/Users/s.kosarev/repo/origin/wmslamoda/tools/extensions/target/classes:/Users/s.kosarev/repo/origin/wmslamoda/wms-authentication-api/target/classes" com.intellij.jpa.console.RemoteJpaServer
2017-10-30 21:59:24,891 [ 990395] DEBUG - #com.intellij.execution.rmi.RemoteProcessSupport - Port/ID: 43664/JpaFacadeImplc9479dbe
2017-10-30 21:59:27,261 [ 992765] WARN - #com.intellij.execution.rmi.RemoteProcessSupport - Oct 30, 2017 9:59:27 PM org.hibernate.jpa.internal.util.LogHelper logPersistenceUnitInformation
2017-10-30 21:59:27,261 [ 992765] WARN - #com.intellij.execution.rmi.RemoteProcessSupport - INFO: HHH000204: Processing PersistenceUnitInfo [
2017-10-30 21:59:27,261 [ 992765] WARN - #com.intellij.execution.rmi.RemoteProcessSupport - name: myWMS
2017-10-30 21:59:27,261 [ 992765] WARN - #com.intellij.execution.rmi.RemoteProcessSupport - ...]
2017-10-30 21:59:27,553 [ 993057] WARN - #com.intellij.execution.rmi.RemoteProcessSupport - Oct 30, 2017 9:59:27 PM org.hibernate.Version logVersion
2017-10-30 21:59:27,553 [ 993057] WARN - #com.intellij.execution.rmi.RemoteProcessSupport - INFO: HHH000412: Hibernate Core {5.2.12.Final}
2017-10-30 21:59:27,565 [ 993069] WARN - #com.intellij.execution.rmi.RemoteProcessSupport - Oct 30, 2017 9:59:27 PM org.hibernate.cfg.Environment <clinit>
2017-10-30 21:59:27,565 [ 993069] WARN - #com.intellij.execution.rmi.RemoteProcessSupport - INFO: HHH000206: hibernate.properties not found
2017-10-30 21:59:27,671 [ 993175] WARN - #com.intellij.execution.rmi.RemoteProcessSupport - Oct 30, 2017 9:59:27 PM org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit>
2017-10-30 21:59:27,671 [ 993175] WARN - #com.intellij.execution.rmi.RemoteProcessSupport - INFO: HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2017-10-30 21:59:27,928 [ 993432] WARN - #com.intellij.execution.rmi.RemoteProcessSupport - Oct 30, 2017 9:59:27 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
2017-10-30 21:59:27,928 [ 993432] WARN - #com.intellij.execution.rmi.RemoteProcessSupport - WARN: HHH10001002: Using Hibernate built-in connection pool (not for production use!)
2017-10-30 21:59:27,988 [ 993492] WARN - #com.intellij.execution.rmi.RemoteProcessSupport - Oct 30, 2017 9:59:27 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
2017-10-30 21:59:27,988 [ 993492] WARN - #com.intellij.execution.rmi.RemoteProcessSupport - INFO: HHH10001005: using driver [org.postgresql.Driver] at URL [jdbc:postgresql://...]
2017-10-30 21:59:27,988 [ 993492] WARN - #com.intellij.execution.rmi.RemoteProcessSupport - Oct 30, 2017 9:59:27 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
2017-10-30 21:59:27,988 [ 993492] WARN - #com.intellij.execution.rmi.RemoteProcessSupport - INFO: HHH10001001: Connection properties: {user=..., password=****}
2017-10-30 21:59:27,988 [ 993492] WARN - #com.intellij.execution.rmi.RemoteProcessSupport - Oct 30, 2017 9:59:27 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
2017-10-30 21:59:27,988 [ 993492] WARN - #com.intellij.execution.rmi.RemoteProcessSupport - INFO: HHH10001003: Autocommit mode: false
2017-10-30 21:59:27,995 [ 993499] WARN - #com.intellij.execution.rmi.RemoteProcessSupport - Oct 30, 2017 9:59:27 PM org.hibernate.engine.jdbc.connections.internal.PooledConnections <init>
2017-10-30 21:59:27,995 [ 993499] WARN - #com.intellij.execution.rmi.RemoteProcessSupport - INFO: HHH000115: Hibernate connection pool size: 20 (min=1)
2017-10-30 21:59:28,203 [ 993707] WARN - #com.intellij.execution.rmi.RemoteProcessSupport - Oct 30, 2017 9:59:28 PM org.hibernate.dialect.Dialect <init>
2017-10-30 21:59:28,203 [ 993707] WARN - #com.intellij.execution.rmi.RemoteProcessSupport - INFO: HHH000400: Using dialect: org.hibernate.dialect.PostgreSQL9Dialect
2017-10-30 21:59:29,565 [ 995069] WARN - #com.intellij.execution.rmi.RemoteProcessSupport - Oct 30, 2017 9:59:29 PM org.hibernate.engine.jdbc.env.internal.LobCreatorBuilderImpl useContextualLobCreation
2017-10-30 21:59:29,565 [ 995069] WARN - #com.intellij.execution.rmi.RemoteProcessSupport - INFO: HHH000424: Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException
2017-10-30 21:59:29,566 [ 995070] WARN - #com.intellij.execution.rmi.RemoteProcessSupport - Oct 30, 2017 9:59:29 PM org.hibernate.type.BasicTypeRegistry register
2017-10-30 21:59:29,566 [ 995070] WARN - #com.intellij.execution.rmi.RemoteProcessSupport - INFO: HHH000270: Type registration [java.util.UUID] overrides previous : org.hibernate.type.UUIDBinaryType@308fbb5b
2017-10-30 21:59:33,811 [ 999315] WARN - #com.intellij.execution.rmi.RemoteProcessSupport - Oct 30, 2017 9:59:33 PM org.hibernate.hql.internal.QueryTranslatorFactoryInitiator initiateService
2017-10-30 21:59:33,811 [ 999315] WARN - #com.intellij.execution.rmi.RemoteProcessSupport - INFO: HHH000397: Using ASTQueryTranslatorFactory
2017-10-30 21:59:34,097 [ 999601] DEBUG - #com.intellij.openapi.editor.impl.DocumentImpl - DocumentEventImpl[myOffset=0, myOldLength=0, myNewLength=82, myOldString='', myNewString='UnsupportedOperationException: org.hibernate.internal.SessionImpl is not supported'].
2017-10-30 21:59:34,297 [ 999801] DEBUG - #com.intellij.openapi.editor.impl.DocumentImpl - DocumentEventImpl[myOffset=66, myOldLength=0, myNewLength=105, myOldString='', myNewString='[2017-10-30 21:59:34] UnsupportedOperationException: org.hibernate.internal.SessionImpl is not supported
'].

 

0

I found so far  in jpa-console.jar 

there is groovy script

org.hibernate.ejb.script

with 

def sql(em, query) {
em.session.getHQLQueryPlan(query, true).getSqlStrings().join(";\n")
}

and RemoteEntityManagerImpl

has methods

private Object invokeHelper(String method, Object... args) throws RemoteException {
try {
String managerClassName = this.myDelegate.getClass().getName();
String name = getHelperScriptName(managerClassName);
URL resource = this.getClass().getResource(name);
if (resource == null) {
throw new UnsupportedOperationException(managerClassName + " is not supported");
} else {
return GroovyHelper.invokeGroovyMethod(resource, method, args);
}
} catch (Exception var6) {
throw this.rethrowRuntimeException(var6);
}
}

private static String getHelperScriptName(String name) {
int idx = name.indexOf(46);
idx = idx < 0 ? idx : name.indexOf(46, idx + 1);
idx = idx < 0 ? idx : name.indexOf(46, idx + 1);
String scriptName = idx < 0 ? name : name.substring(0, idx);
return scriptName + ".script";
}
0

fixed it

added to Idea's plugin jpa-console.jar

located at 

IntelliJ IDEA.app/Contents/plugins/JavaEE/lib

a bit modified script for Hibernate 5

jar uf jpa-console.jar com/intellij/jpa/remote/impl/org.hibernate.internal.script

package com.intellij.jpa.remote.impl

/**
* @author gregsh
*/
class HibernateHelper {
def sql(em, query) {
em.session.getQueryPlan(query, true).getSqlStrings().join(";\n")
}
def ddl(em, unitName) {
def cfg;
def dialect;
cfg = em.session.factory.serviceRegistry.configuration
dialect = org.hibernate.dialect.Dialect.getDialect(cfg.getProperties())
def create = cfg.generateSchemaCreationScript(dialect).join(";\n\n").replace(", ", ",\n ")
def drop = cfg.generateDropSchemaScript(dialect).join(";\n")
"-- Create schema script\n" + create + "\n\n-- Drop schema script\n" + drop
}
}

it works with current Hibernate dependency

<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.2.12.Final</version>
</dependency>

 

2

I'm also getting this error in IDEA 2016, 2017, 2018


UnsupportedOperationException: org.hibernate.jpa.internal.EntityManagerImpl is not supported

0

请先登录再写评论。