facebook

NOOB: sprng/hbrnte/pstgres progess, but save not commiting?

  1. MyEclipse Archived
  2.  > 
  3. Database Tools (DB Explorer, Hibernate, etc.)
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #254185 Reply

    Dan
    Member

    Hi 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;
    }
    }

    #254220 Reply

    Riyad Kalla
    Member

    Another 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=

Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: NOOB: sprng/hbrnte/pstgres progess, but save not commiting?

You must be logged in to post in the forum log in