-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: getHibernateTemplate().get() Returns null, the id is correct
PostPosted: Tue May 20, 2008 8:24 am 
Newbie

Joined: Tue May 20, 2008 6:54 am
Posts: 3
Location: Indonesia
DA, I found cute thing with hibernate, please help me

I use appfuse-spring-hibernate, I have pojos with composite-keys, some of them is Deposito, Kredit, and Retail. every daoHibernate that that doing get, save, or delete are works well except for Kredit.

Kredit and Retail has exactly the same primary keys, so I use one object and named it KreditRetailPk, all of methods in the RetailDaoHibernate works fine, while the KreditDaoHibernate, getKredits() and getKreditPaging() are fine except for the getKredit() method. here's the error:
Code:
Data Access Failure

Object of class [model.Kredit] with identifier [model.KreditRetailPk@16b998f[dimProduct=model.DimProduct@ bla bla]: not found


I use the usual syntax to get my object, and all is works except for Kredit, here's my code:
Code:
        public Kredit getKredit(KreditRetailPk kreditRetailPk) {
      Kredit kredit = (Kredit) getHibernateTemplate().get(Kredit.class, kreditRetailPk);
      if (kredit == null) {
            throw new ObjectRetrievalFailureException(Kredit.class, kreditRetailPk);
        }
        return kredit;
   }


I copy the hibernate syntax and try it in my Oracle sqlDeveloper and nothing matter, I got one record I need. but when I debug it, when reach the conditional if (kredit == null) , the kredit is null.

Before going to the error page, my application lists a list of Kredits (I use paging) and it's fine, but when I click one of then to edit it, it's gonne be error.

I already create KreditDaoTest and RetailDaoTest, which there are two checking inside of them get and getAllPaging, everything's success except for getKredit. Here's my code for getKredit:
Code:
public void testGetKredit() throws Exception {
       dimTime = dtimeDao.getDimTime(new Long(6066));
       dimLocation = dlocDao.getDimLocation("010");
       dimCurrency = dcurrDao.getDimCurrency("IDR");      
       dimProduct = dprodDao.getDimProduct(new Long(56));
       dimCustomer = dcustDao.getDimCustomer("01051652");
       accountNumber = "0001KPG";
       
       KreditRetailPk kreditRetailPk = new KreditRetailPk(accountNumber, dimTime, dimLocation, dimCurrency, dimProduct, dimCustomer);
      
        kredit = dao.getKredit(kreditRetailPk);
        assertNotNull(kredit);
        assertEquals(new Long("IDARNI"), kredit.getDebitorName());
    }


It's exactly the same with testGetRetail, and here's my error in test:
Code:
KreditRetailPk@16b998f[dimProduct=model.DimProduct@ bla bla]: not found
org.springframework.orm.ObjectRetrievalFailureException: Object of class [model.Kredit] with identifier [model.KreditRetailPk@4e21db[dimProduct=DimProduct@509df8bla bla]: not found
at id.co.sigma.lbu.dao.hibernate.KreditDaoHibernate.getKredit(KreditDaoHibernate.java:21)
at id.co.sigma.lbu.dao.KreditDaoTest.testGetKredit(KreditDaoTest.java:68)
at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:69)

So, anymaster have an idea? I already frustating for this case[/code]

_________________
^0^


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.