Announcement Announcement Module
Collapse
No announcement yet.
Problem with HibernateCallback Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem with HibernateCallback

    I'm trying to reach the criteria api within the HibernateCallBack.
    I' don't undestand while my code can't compile.

    I'm getting "the method createCriteria(Session,Class) is undefined for the type <anonymous implementation oh HibernateCallback> compilation error message.

    here is the method in cause :

    public TStructureLibelle findByCrit(final String codeStructure,final Date now) throws FinderException
    {
    TStructureLibelle result=null;
    result=(TStructureLibelle)getHibernateTemplate().e xecute(
    new HibernateCallback()
    {
    public Object doInHibernate(Session session) throws HibernateException
    {
    Criteria criteria=createCriteria(session,TStructureLibelle. class);
    criteria.add(Expression.eq("structure.codeStructur e",codeStructure));
    criteria.add(Expression.le("dateDebutValidite",now ));
    criteria.add(Expression.ge("dateFinValidite",now)) ;

    return criteria.uniqueResult();

    }
    });

    return result;
    }
    My class extends HibernateDaoSupport

    Can someone please tells me what's wrong in my code.

    thanks in advance

    Meissa

  • #2
    Re: Problem with HibernateCallback

    Originally posted by meissa
    I'm trying to reach the criteria api within the HibernateCallBack.
    I' don't undestand while my code can't compile.

    I'm getting "the method createCriteria(Session,Class) is undefined for the type <anonymous implementation oh HibernateCallback> compilation error message.

    here is the method in cause :

    public TStructureLibelle findByCrit(final String codeStructure,final Date now) throws FinderException
    {
    TStructureLibelle result=null;
    result=(TStructureLibelle)getHibernateTemplate().e xecute(
    new HibernateCallback()
    {
    public Object doInHibernate(Session session) throws HibernateException
    {
    Criteria criteria=createCriteria(session,TStructureLibelle. class);
    criteria.add(Expression.eq("structure.codeStructur e",codeStructure));
    criteria.add(Expression.le("dateDebutValidite",now ));
    criteria.add(Expression.ge("dateFinValidite",now)) ;

    return criteria.uniqueResult();

    }
    });

    return result;
    }
    My class extends HibernateDaoSupport

    Can someone please tells me what's wrong in my code.

    thanks in advance

    Meissa
    Sorry, it was wrong to call
    Criteria criteria=createCriteria(session,TStructureLibelle. class);
    The correct call is session.createCriteria(Class)

    Comment

    Working...
    X