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

  • Problem with Lazy fetching strategy

    'm setting my fetch association mapping to lazy in order to reduce database load.
    Doing so gives me the flexibility to change fetchMode of associated entities at runtime
    through the criteria api.

    The problem I'm having is when I try to load my entity itself.
    I'm getting an exception (see the extract below)

    here is my load code:

    public TStructure findById(String codeStructure) throws FinderException
    {
    TStructure result=null;
    try
    {
    result=(TStructure)getHibernateTemplate().load(TSt ructure.class,codeStructure);
    }
    catch (DataAccessException e)
    {
    String errorMessage=" Echec du chargement de la structure"+codeStructure;
    log.error(e+errorMessage);

    throw new FinderException(errorMessage,e);
    }
    return result;
    }


    here is the exception :

    ERROR [LazyInitializer] Exception initializing proxy
    net.sf.hibernate.HibernateException: Could not initialize proxy - the owning Session was closed

    Can someone tells me how I could load my item without changing the lazy fetch mapping mode.

    thanks in advance

  • #2
    could you send spring configuration file and hibernate mapping files?

    Comment

    Working...
    X