Toko Ides
Toko Ides

Reputation: 3

Jhipster 5, saving failed when using relationship to Jhipster User

I am using example from https://github.com/mraible/jhipster5-demo. I used Postgresql for dev and pro. Project with entities are generated successfully.

When I create new Blog and saving, i got this error.

Exception in com.asdev.blog.web.rest.BlogResource.createBlog() with cause = 'java.lang.IllegalStateException: org.hibernate.TransientPropertyValueException: object references an unsaved transient instance - save the transient instance before flushing : com.asdev.blog.domain.Blog.user -> com.asdev.blog.domain.User' and exception = 'org.hibernate.TransientPropertyValueException: object references an unsaved transient instance - save the transient instance before flushing : com.asdev.blog.domain.Blog.user -> com.asdev.blog.domain.User; nested exception is java.lang.IllegalStateException: org.hibernate.TransientPropertyValueException: object references an unsaved transient instance - save the transient instance before flushing : com.asdev.blog.domain.Blog.user -> com.asdev.blog.domain.User'

I did with jhipster 4 and worked.

Any suggestions?

Upvotes: 0

Views: 284

Answers (1)

Akira Abe
Akira Abe

Reputation: 1

In this case, it is probably because the value held in the field when saving the Many side(Blog) is in an unmanaged state on JPA. As a countermeasure, I modified Controller, you can solve by retrieving the object on the One side(User) and resetting it to the Many side field.

Upvotes: 0

Related Questions