save method - doesn't flush the Session after an exception occurs

后端 未结 3 468
春和景丽
春和景丽 2020-12-15 22:43
public class SoftwareTest extends UnitTest {

    @Before
    public void setup() {
        Fixtures.deleteAll(); // will fail if comment that. why?????
    }

    @         


        
3条回答
  •  借酒劲吻你
    2020-12-15 22:48

    From the error:

    org.hibernate.AssertionFailure: null id in models.Software entry (don't flush the Session after an exception occurs)

    We can see that a session exception has happened before. The point where this org.hibernate.AssertionFailure is thrown is not the point where the error ocurred.

    That is: Something is suppressing the original exception.

    So look for other possible points of error. A save() or saveOrUpdate() is possibly trying to persist an entity with a null field where, in the table, the column is NOT NULL.

    In my case, the real exception was taking place inside a try/catch {} block where the catch suppressed the exception (didn't rethrow or warn me about it).

提交回复
热议问题