I have below code in my service class. This code is called twice from 2 different methods as part of a functionality.
//Some code here...
LOG.info("###Inside customer interceptor");
try
{
customerDao.save(customer);
}
catch (final Exception exp)
{
//some code here too...
}
When it is first time called from first method and executed, I can see that there is a select SQL statement printed in tomcat console, but there is no update SQL statement as I expected(May be because of the fact that Hibernate doesn't issue an insert/update immediately). Immediately When this code block is called again from second method, I see a SQL select statement and then a SQL update statement in tomcat console, and immediately after that I see a big fat org.hibernate.NonUniqueObjectException. which as I can understand coming because the earlier entity was still attached to session and not committed to DB.
However when I go and see the database I find the values saved in the database were of the object from first call and not the second one as I expected. Is this normal or am I missing something here?
I am using Spring's annotation(@Transactional) driven transaction strategy.