- This topic has 1 reply, 2 voices, and was last updated 18 years, 6 months ago by Riyad Kalla.
-
AuthorPosts
-
DanMemberHi all, I have one more critical hurdle to hurdle before I can begin real development using these techs, I need to be able to insert/update/query, but my test is failing to insert/update (I call save..no error, yet nothing pops into the database..do i need to call commit expliclty and if so on what object?).
Namely for my demo/test code, I am attempting to create a new account (i.e. database entry), from the web I have made to this far:
generated the Account, AbstractAcount, and AccountDao, I have 2 tables: Account, Statuscode (enum of account status codes)
The testAccountCreate method performs 2 db calls, query to retrieve a valid statuscode object, then a save opertion on the AccountDao for the new account object. No errors are generated.. any thoughts as to why the SAVE call in the testAccountCreate is not commiting?
Obviously I will be using some type of transaction management, but for now I’m just trying to get the basics working..
now my test code:
code snippit
—————public void setUp()
{
try
{
logger.info(“setUp Called”);
appctx = new FileSystemXmlApplicationContext(“src/bn-spring.xml”);
accountDAO = (AccountDAO)appctx.getBean(“AccountDAO”);
statusDAO = (StatuscodeDAO)appctx.getBean(“StatuscodeDAO”);
}
catch(RuntimeException re)
{
re.printStackTrace();
}
}public void testCreateAccount()
{
try
{
logger.info(“testCreateAccountCalled”);
Statuscode status = new Statuscode(“pending”);
List<Statuscode> l = statusDAO.findByExample(status);
if (l.size() > 0)
{
Account acc = new Account(l.get(0), new Date(), “John”, “Doe”, “johndoe”, “foobar@foo.com”);
accountDAO.save(acc);
}
logger.info(“testCreateAccount, completed”);
}
catch(RuntimeException re)
{
re.printStackTrace();
}
}AccountDAO.save method (autogenerated by myeclipse)
public void save(Account transientInstance) {
log.debug(“saving Account instance”);
try {
getHibernateTemplate().saveOrUpdate(transientInstance);
log.debug(“save successful”);
} catch (RuntimeException re) {
log.error(“save failed”, re);
throw re;
}
}
Riyad KallaMemberAnother user asked almost the exact same question recently, we will reply to the first thread here:
https://www.genuitec.com/forums/topic/object-are-not-save-without-any-exception/&highlight= -
AuthorPosts