0
我想有以下行从JPA的EntityManager的获得Hibernate的SessionFactory的:SessionFactory的抛出异常
@PersistenceContext
EntityManager manager;
public SessionFactory getSessionFactory(){
sessionFactory = manager.unwrap(SessionFactory.class);
}
但引发此异常:
org.springframework.orm.jpa.JpaSystemException: Hibernate cannot unwrap interface org.hibernate.SessionFactory; nested exception is javax.persistence.PersistenceException: Hibernate cannot unwrap interface org.hibernate.SessionFactory
at org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:418)
...
Caused by: javax.persistence.PersistenceException: Hibernate cannot unwrap interface org.hibernate.SessionFactory
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.unwrap(AbstractEntityManagerImpl.java:1489)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
...
可能是什么原因为了这?
在此先感谢
它的工作!现在我得到一个错误“没有配置CurrentSessionContext!”,我想我错误地使用了它? –