java - Hibernate Exception help: TransientObjectException -


When I try to update an object, I get the following exception:

Org.hibernate.TransientObjectException: Object references an unsaved transient example - Save momentary examples before flushing: ......

Can anyone help ???

The object that I am trying to update has set the 'lazy' attribute to the wrong mapping file. It seems like being in hibernation, I am hoping to save the hair object before it flashes the update ???

Edit (Added):

  & lt; Hibernate-maping & gt; & Lt; Class name = "utils.message.Message" table = "message" & gt; & Lt; Id name = "id" column = "message_id" & gt; & Lt; Generator class = "parent" /> & Lt; / Id & gt; & Lt; Property Name = "message_text" column = "message_text" /> & Lt; Property Name = "message_file" column = "message_file" /> & Lt; Property Name = "is_active" column = "is_active" type = "boolean" /> & Lt; Property Name = "is_global" column = "is_global" type = "boolean" /> & Lt; Property Name = "Start" column = "Start" type = "java.util.Date" /> & Lt; Property Name = "End" Column = "End" Type = "java.util.Date" /> & Lt; Property Name = "Last_Account" column = "Last_Account" type = "java.util.Date" /> & Lt; Many-to-one names = "last_updated" class = "utils.user.user" column = "last_updated" by lazy = "false" /> & Lt; Many-to-one names = "health department" category = "utils.healthdepartment.HealthDepartment" column = "health_department_id" lazy = "false" /> & Lt; / Square & gt; & Lt; / Hibernate-mapping & gt;  

Transient object findings occur when you save an object that is transient Refers to another object (meaning "default" is the identifier value, often zero) and then flush the session. This usually happens when you are making a full graph of the new object but have not explicitly saved them all. There are two ways to work around it:

  1. As you suggest, you can use cascading to save other related objects. However, cascading was not in fact as an alternative solution for TOE but rather as a convenience to save a group of related items, which are often manipulated simultaneously. If you separate your objects without fully connected data and save it with cascading enable, you can inadvertently remove data that you do not want to lose.
  2. Make sure that all the transient objects in your graph are clearly saved as part of your unit of work. This is actually a matter of understanding how your application is creating an Object graph and who C institutions are transient and can be continuous or different.

I will recommend this whole chapter by hibernating documents to fully understand the vocabulary of transient, continuous and different:


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -