I created a fresh grails 5.1.2 project, installed spring-security (directly, not via plugin) and installed grails-spring-websocket:2.5.0.RC1.
It seemed that everything works fine until I started to modify domain objects within a websocket controller:
@MessageMapping("/edit")
@SendTo("/topic/result")
protected String edit(String message) {
Book.withTransaction {
def book = Book.findByName("Book1")
book.pages = 1
book.save(flush: true)
}
}
This snippet it part of the Book-controller. I added the .withTransaction
part when I got error messages telling me that there is no hibernate session.
Now, the result is somehow random. The code works sometimes and sometimes I get an error message saying
Batch update returned unexpected row count from update [0]
any help would be highly appreciated :-)
CodePudding user response:
ok, I was searching in the wrong place:
my application gets lots of messages for the same domain object. All those messages try to change the same property at the same time.
I will now change my data structure to fit.