mdelapenya/liferay-portal — pull request #15 by zberentey (2012-11-06 11:47:48+00:00)
Title: LPS-30457

Hi Manuel, the social activity counter service uses REQUIRES_NEW for adding new counters, so setting @Transactional on the test class causes constraint violation errors. I think it is because at some point the session still thinks that it hasn't written an object into the database while in reality it already has. Could be that the hibernate object get's rolled back after that service call - because it goes through all AOP advices - but since it has the REQUIRES_NEW, the database transaction commits. This results in the next fetch wanting to flush the now incorrect session and trying to re-insert the object, which of course fails. Now if we remove the @Transaction annotation from the class, unfortunately we need to put back the clean-up in a tearDown() method. Please see my changes...