I have a problem with spring-data / hibernate and ...
# spring
I have a problem with spring-data / hibernate and detached entities. This isn't particularly a kotlin-problem - but since I'm doing the whole project in kotlin, and the example code is kotlin, I'm hoping, that it is still acceptable to post this here. The gist of it is, that im calling
Copy code
val adminRole = roles.findByName("admin")!!
val adminUser = BackendUser("admin", adminRole
    // some more data here
and get org.hibernate.PersistentObjectException: detached entity passed to persist: my.package.name.user.UserRole More details are in this SO post: https://stackoverflow.com/questions/62874155/spring-data-hibernate-detached-entity-passed-to-persist Any help would be appreciated.
where are your transaction boundaries?
🙏 1
someone on SO pointed out, that i the @transactional annotation possibly isn't picked up on that private method and suggested moving it to its own service - did that, and it appears that has solved the problem.
yeah that was me 🙂
👍 1
glad it helped
you can only annotate public methods in spring in general. just fyi