Play! framework immediate save?

前端 未结 3 985
生来不讨喜
生来不讨喜 2021-02-20 02:27

In Play! if you call this:

void method()
{
User u = User();
u.name = \"bob\";
u.save();
while(true){/* endless loop */}
}

Nothing will actually

3条回答
  •  没有蜡笔的小新
    2021-02-20 03:24

    As already said by Andrei Bodnarescu, you can use JPA.em().flush() or User.em().flush() to flush persistence context explicitly.

    Note, however, that doing so won't make the saved entity immediately available to other transactions, since the current transaction should be committed first. You can commit the current transaction as JPA.em().getTransaction().commit().

提交回复
热议问题