Announcement Announcement Module
Collapse
No announcement yet.
No Hibernate Session bound to thread,configuration does not allow of non-transaction Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • No Hibernate Session bound to thread,configuration does not allow of non-transaction

    Hi

    Below is the complete scenario of my problem .. Please help

    Here is my XML configuration

    <bean id="feedDao" class="com.model.dao.hibernate.FeedDaoHibernateImp l">
    <property name="hibernateTemplate">
    <ref bean="hibernateTemplate" />
    </property>
    </bean>


    <bean id="rssFeedMainServiceTarget" class="com.quanat.service.RSSFeedMainService">
    <property name="feedDao" ref="feedDao" />
    </bean>

    <bean id="rssFeedMainService" class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean">
    <property name="transactionManager">
    <ref local="transactionManager" />
    </property>
    <property name="target">
    <ref local="rssFeedMainServiceTarget" />
    </property>
    <property name="transactionAttributes">
    <props>
    <prop key="startRetriving">PROPAGATION_REQUIRED,-com.quanat.exception.ApplicationException</prop>
    </props>
    </property>
    </bean>



    <bean id="rssFeedMainServiceJob" class="org.springframework.scheduling.quartz.Metho dInvokingJobDetailFactoryBean">
    <property name="targetObject">
    <ref local="rssFeedMainService" />
    </property>
    <property name="targetMethod" value="startRetriving" />
    </bean>

    <bean id="rssFeedMainServiceTrigger" class="org.springframework.scheduling.quartz.Simpl eTriggerBean">
    <property name="jobDetail">
    <ref local="rssFeedMainServiceJob" />
    </property>
    <property name="startDelay" value="0" />
    <property name="repeatInterval" value="3600000" />

    </bean>


    Here is my method in DAO class

    public List<Feed> getAllFeeds(Long statusId) {
    Criteria criteria = getHibernateTemplate().getSessionFactory()
    .getCurrentSession().createCriteria(Feed.class);
    if (!Utils.isEmpty(statusId)) {
    criteria.add(Restrictions.eq("isActive", statusId));
    }
    criteria.setResultTransformer(CriteriaSpecificatio n.DISTINCT_ROOT_ENTITY);
    return criteria.list();
    }


    when I simply use feedDao in startRetriving method it works fine as shown below.

    public void startRetriving() throws ApplicationException {
    List<Feed> feedList = feedDao.getAllFeeds(new Long(1));
    }


    But when I use feedDao in annonymous innerclass that is also declared in StartRetriving method as shown below than exception occur "No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here"

    public void startRetriving() throws ApplicationException {

    feedr.addOnNotificationHandler(new InnerService() {

    public void onNotification(final SuperfeedrEventExtension event)
    {
    List<Feed> feedList = feedDao.getAllFeeds(new Long(1));

    }
    });

  • #2
    Hello adnanjvd

    1) use code tags, is more readable for us
    2) Do you receive some error?, if yes, copy here the complete error stack trace
    with that information, we have a better idea about your problem

    Comment

    Working...
    X