留言板

HELP!: No Hibernate Session bound to thread

thumbnail
petar banicevic,修改在15 年前。

HELP!: No Hibernate Session bound to thread

Junior Member 帖子: 73 加入日期: 08-5-27 最近的帖子
I have extended a table by adding few aditional fields as described in wiki. I am getting this error:

10:36:02,953 ERROR [HibernateUtil:204] Caught HibernateException
10:36:02,968 ERROR [HibernateUtil:210] org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here
org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here
at com.liferay.util.spring.hibernate.SessionFactoryInvocationHandler.invoke(SessionFactoryInvocationHandler.java:68)
at $Proxy1.getCurrentSession(Unknown Source)
at com.liferay.portal.spring.hibernate.HibernateUtil.openSession(HibernateUtil.java:185)
at com.liferay.portal.service.persistence.BasePersistence.openSession(BasePersistence.java:73)
at com.ibm.eures.portal.jobfair.service.persistence.joboffererPersistenceImpl.fetchByPrimaryKey(joboffererPersistenceImpl.java:223)
at com.ibm.eures.portal.jobfair.service.persistence.joboffererPersistenceImpl.findByPrimaryKey(joboffererPersistenceImpl.java:204)
at com.ibm.eures.portal.jobfair.service.persistence.joboffererUtil.findByPrimaryKey(joboffererUtil.java:64)
at com.ibm.eures.portal.jobfair.mbeans.CompanyInfo.init(CompanyInfo.java:31)
at com.ibm.eures.portal.jobfair.mbeans.CompanyInfo.getLegalName(CompanyInfo.java:54)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)

It ocures in generated files xxxxPersistenceImpl.java (here, particulary joboffererPersistenceImpl.java)

public jobofferer fetchByPrimaryKey(long userId) throws SystemException {
Session session = null;

try {
session = openSession(); // <-- here is exception: No Hibernate Session bound to thread

return (jobofferer) session.get(joboffererImpl.class,new Long(userId));
} catch (Exception e) {
throw HibernateUtil.processException(e);
} finally {
closeSession(session);
}
}

I have seen some discussion on forum regarding this error, can someone help? How to bind hibernate transaction or whatever this means ????

Thanks
thumbnail
Bruno Farache,修改在15 年前。

RE: HELP!: No Hibernate Session bound to thread

Liferay Master 帖子: 603 加入日期: 07-5-14 最近的帖子
Petar, you can't call joboffererUtil.findByPrimaryKey directly from CompanyInfo.init.

Do that from joboffererLocalServiceImpl or joboffererServiceImpl, the persistence class will be injected by spring and you will be able to call using the joboffererPersistence variable.
thumbnail
petar banicevic,修改在15 年前。

RE: HELP!: No Hibernate Session bound to thread

Junior Member 帖子: 73 加入日期: 08-5-27 最近的帖子
Thanks... that was the problem. I considered that there's no difference.... but aparently there is.

Many thanks !

P.
Ashok Guduru,修改在6 年前。

RE: HELP!: No Hibernate Session bound to thread

New Member 发布: 1 加入日期: 17-8-22 最近的帖子
Excellent. Thanks peter. I know this is 10 years old answer. many thanks.