zdravim konferenciu,

pouzivam Hibernate a Spring. potrebujem vykonat jeden update nad DB mimo
klasickeho pristupu Hibernate pomocou prikazu createSQLQuery:

public void updateZdroj(final Long id) {

final HibernateCallback callback = new HibernateCallback() {
            public Object doInHibernate(final Session session) throws
HibernateException {
                session.beginTransaction();
                int result = session.createSQLQuery("update zdroj set hodnota =
hodnota + 1 where id = " + id).executeUpdate();
                session.getTransaction().commit();
                return result;
            }
          };
          getHibernateTemplate().execute(callback);
}

tento kod je v triede ZdrojDaoHibernate (implements ZrojDao).

skusal som aj dat
@Transactional (propagation=Propagation.REQUIRED)
public interface ZdrojDao extends GenericDao<Carrier, Long> {

aj konktrentne nad funkciu updateZdroj:
@Transactional (readOnly=false)
void updateZdroj(Long id);

a skusal som aj dat parameter Hibernate:

<prop key="hibernate.current_session_context_class">thread</prop>

bohuzial nic nepomohlo chyba je vzdy nasledovna:

org.hibernate.HibernateException: No Hibernate Session bound to thread, and
configuration does not allow creation of non-transactional one here
        
org.springframework.orm.hibernate3.SpringSessionContext.currentSession(SpringSessionContext.java:63)
        
org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:574)


nepoznate niekto presny postup ako pouzivat createSQLQuery?

dakujem

Ivan

________________________________________________
Message sent using Webmail 2.7.9

Odpovedet emailem