Results 1 to 2 of 2

Thread: HibernateTemplate.load

  1. #1
    Join Date
    Aug 2004
    Posts
    10

    Default HibernateTemplate.load

    Hello All

    I think within HibernateTemplate has one bug in load method, when I call load method with Composite PrimaryKey in ID, the return object is null, with HibernateObjectRetrievalFailureException Exception. but a ensure that ID is with valid data.

    Code:
    public Object retrieve(Object dataObject, Serializable id)  {
    try {
      if (dataObject != null && id != null) {
         HibernateTemplate template = new HibernateTemplate  (getSessionFactory());
         retorno = template.load(dataObject.getClass(),id);
      }
    }
    catch (HibernateObjectRetrievalFailureException e) {
       retorno = null;
    }
    catch (Exception e) {
      e.printStackTrace();
    }
    return retorno;
    }
    Here the code where a call the above method
    Code:
    VendedorClientePOPK vendedorClientePK = new VendedorClientePOPK();
    VendedorClientePO   vendedorCliente   = new VendedorClientePO();
    
    vendedorClientePK.setCodCliente( Util.getCnpj(nrCgc,nrFil,nrDc)  );
    vendedorClientePK.setCodVendedor(codVendedor);
    VendedorClientePO vc =  (VendedorClientePO) getGenericDao().retrieve(vendedorCliente, vendedorClientePK);

  2. #2
    Join Date
    Aug 2004
    Location
    Toronto, Canada
    Posts
    736

    Default

    HibernateTemplate.load() is just a simple wrapper around Hibernte's Session.load(), just ensuring that the Session lifecycle is properly managed.

    If you are getting no results back from your load, it's a Hibernate config/usage issue, and nothing to do with Spring...
    Colin Sampaleanu
    SpringSource - http://www.springsource.com

Posting Permissions

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