Hibernate (annotation): Error: TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing

March 27th, 2009 by jeremychone

If you get an error like this one

Hibernate: Error: TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing..

It is probably because you did not annotate your ManyToOne with the Hibernate SAVE_UPATE Cascade annotation:

@ManyToOne()
@Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE})
public Category getCategory() {
        return category;
}

Note, putting only

@ManyToOne(cascade = {CascadeType.MERGE,CascadeType.PERSIST})
public Category getCategory() {

Will not resolve the issue.

One Response to “Hibernate (annotation): Error: TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing”

  1. bydan Says:

    i resolve some aspect with put null the relationship object, then no execute cascade operation.

    It can help you or not

Leave a Reply