org.hibernate.TransientObjectException:

Basically This exception occurs when we use Relationships(OneToOne,OneToMany,ManyToMany) between the Two Objects and not provide the cascade  types. So if you get the following exception add @ManyToMany(cascade=CascadeType.ALL,fetch=FetchType.LAZY) etc... Exception in thread "main" org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: org.shashank.Users (for Ex:) at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:243) at org.hibernate.type.EntityType.getIdentifier(EntityType.java:456) at org.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:121) … Continue reading org.hibernate.TransientObjectException:

Advertisements