java - Hibernate throws TransientPropertyValueException when saving an entity -
I have two related institutions, organizations and registrations, such as registration and organization there are many relationships, The institution must obtain registration entries.
institutions and relationship mappings:
@ Antiti qualified public class registration {@NotNull @ManyToOne (optional = false) insert @ Jonk column (updating qualified = false, = Wrong) Private Institute Institute; } @Entity bring public square Institution {@OneToMany (cascade = {CascadeType.REMOVE, CascadeType.MERGE} = FetchType.EAGER, mappedBy = "body", private set orphanRemoval = true) & lt; Registration & gt; Registration; }
and error trace is available:
[INFO] 04: 34: 26,043 warning [org.hibernate.action.internal.UnresolvedEntityInsertActions] (http -Localhost / 127.0.0.1: 8888-4) HHH 000437: Attempts to save one or more organizations who have a non-ineligible affiliation with the unmanned transient unit. Before saving these dependent institutions, the unstated transient entity should be saved in an operation. [Information] Unsaved transient unit: ([com.bitrunk.apps.nussa.client.shared.Institution # & lt; null & gt;]) [information] Dependent entities: ([[com.bitrunk.apps.nussa .client.shared.ign registration # & lt; null & gt;]]] [info] non-futile association (s): ([com.bitrunk.apps.nussa.client.shared.Registration.institution]) [info] 04: 34: 26,046 eRROR [stderr] (http- localhost / 127.0.0.1: 8888-4) java.lang.IllegalStateException: org.hibernate.TransientPropertyValueException: not-null property reference a transient values - transient examples of current operation First must be saved:
Error: Generated by: org.hibernate.TransientPropertyValueException: empty properties a momentary value's reference - current transient instance before the operation must save: Registration.institution -> entity
When it is quite strange Registration , The user already selects his organization from entries in DB using its dropdown widget, such as the registration website is supposed to point to an object from DB The amazes me that this error is what and how to fix it.
Please, like yesterday, I need a fix, all thanks.
Your current mapping registration / institution does not set up an owner of the association.
-
If you want to control registration (most common), then this is your mapping:
@interity public class registration {@ NotNull @ManyToOne (optional = false) Private Institute Institute; } @Entity bring public square Institution {@OneToMany (cascade = {CascadeType.REMOVE, CascadeType.MERGE} = FetchType.EAGER, mappedBy = "body", private set orphanRemoval = true) & lt; Registration & gt; Registration; }
Code> @Entity Public Class Registration {@NotNull @ManyToOne (optional = false) @JoinColumn (updatable = false, insertable = false) Private Institute Institute; } @Entity public square Institution private set {@OneToMany (cascade = {CascadeType.REMOVE, CascadeType.MERGE} bringing = FetchType.EAGER, orphanRemoval = true) & lt; Registration & gt; Registration; }
both of you ( updatable = false
, insertable = false
) and maps
Because then the union can be controlled due to none of this conference, which tells Hibernate what database during synchronizing the object state with the database.
Comments
Post a Comment