Search code examples
hibernatespringstack-overflow

StackOverflowError while reading then deleting object with hibernate


I am reading an objects and then simply deleting it and it throws java.lang.StackOverflowError!

public class TestDummy extends TestCase {

    @Autowired
    private ApplicationContext context;

    @Autowired
    private AccountDao accountDao;



public void testDeleteAccount(){

        Account acc = accountDao.get("9BE4BFA718EA4B4EE044000077B05A84");
        System.out.println("Account name is "+acc.getAccountName());
        accountDao.delete(a);

    }

}

accountDao and context are instantiating good.

here is get() and delete() methods

   public Account get(String id) {
    Account acc = getHibernateTemplate().get(Account.class, id);
    return  acc;
}

public void delete(Account account) {
    delete(account);
}

I wonder what can be recursively happening here!

Please advice.


Solution

  • public void delete(Account account) 
    {
       delete(account);
    }
    

    No wonder you get SO.