Results 1 to 2 of 2

Thread: Problem with HibernateCallback

  1. #1
    Join Date
    Oct 2004
    Location
    Paris (France)
    Posts
    26

    Default 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. #2
    Join Date
    Oct 2004
    Location
    Paris (France)
    Posts
    26

    Default Re: Problem with HibernateCallback

    Quote 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)

Similar Threads

  1. Replies: 11
    Last Post: Aug 20th, 2009, 12:24 PM
  2. Replies: 1
    Last Post: Jul 5th, 2005, 03:48 AM
  3. pagination and continuation problem in SWF
    By yfmoan in forum Web Flow
    Replies: 6
    Last Post: Jun 29th, 2005, 03:42 AM
  4. Problem with HibernateCallback
    By meissa in forum Data
    Replies: 3
    Last Post: Mar 18th, 2005, 12:12 PM
  5. Lazy Load Problem when Doing UnitTest
    By yoshi in forum Data
    Replies: 7
    Last Post: Sep 29th, 2004, 10:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •