コードに問題があります:
private EntityManager entityManager;
public EntityManager getEntityManager() {
if (entityManager == null) {
entityManager = Persistence.createEntityManagerFactory("pu-mypu").createEntityManager();
}
return entityManager;
}
public <T> T get(Long id, Class<T> type) {
return getEntityManager().find(type, id);
}
電話をかけようとすると、MyPojo p = get(1, MyPojo.cass);
それはスローします:
[ERROR] Caused by: org.hibernate.exception.GenericJDBCException: ERROR: current transaction is aborted, commands ignored until end of transaction block
[ERROR] at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:54)
[ERROR] at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125)
[ERROR] at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110)
[ERROR] at org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:129)
[ERROR] at org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:81)
[ERROR] at $Proxy175.executeQuery(Unknown Source)
[ERROR] at org.hibernate.loader.Loader.getResultSet(Loader.java:2031)
[ERROR] at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1832)
[ERROR] at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1811)
[ERROR] at org.hibernate.loader.Loader.doQuery(Loader.java:899)
[ERROR] at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:341)
[ERROR] at org.hibernate.loader.Loader.doList(Loader.java:2516)
[ERROR] at org.hibernate.loader.Loader.doList(Loader.java:2502)
[ERROR] at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2332)
[ERROR] at org.hibernate.loader.Loader.list(Loader.java:2327)
[ERROR] at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:490)
[ERROR] at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:355)
[ERROR] at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:195)
[ERROR] at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1247)
[ERROR] at org.hibernate.internal.QueryImpl.list(QueryImpl.java:101)
[ERROR] at org.hibernate.ejb.QueryImpl.getSingleResult(QueryImpl.java:283)
[ERROR] ... 48 more