TransientObjectException Java Origin: Application & API OSI layer 7 · Application Last updated 13 Oct 2026

org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing

An entity references another entity that hasn’t been saved yet, and no cascade is configured.

Exact message you may see object references an unsaved transient instance
Seen on: Java

Meaning

Hibernate won’t persist the referenced object implicitly unless the relationship cascades PERSIST/ALL.

Common causes

  • New child/parent not saved before flush
  • Missing cascade = CascadeType.PERSIST
  • Detached vs new instance confusion

⚡ Quick fix

  1. Save the referenced entity first
  2. Add cascade on the owning relation
  3. Load existing entities with getReferenceById instead of new

Detailed fix by platform

Java

  1. @OneToMany(mappedBy = "order", cascade = CascadeType.ALL)

How to diagnose

  1. Reference — Which entity is transient?
  2. Cascade — Configured on that relation?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

Hibernate ConstraintViolationException — org.hibernate.exception.ConstraintViolationException: could not execute statement (Java)Hibernate ConstraintV…LazyInitializationException — org.hibernate.LazyInitializationException: could not initialize proxy - no Session (Java)LazyInitializationExc…N+1 queries — Performance: N+1 query problem (one query per row in a loop) (SQL)N+1 queriesNonUniqueResultException — IncorrectResultSizeDataAccessException: query did not return a unique result: 2 (Java)NonUniqueResultExcept…SequelizeConnectionRefusedError — SequelizeConnectionRefusedError: connect ECONNREFUSED 127.0.0.1:5432 (Node.js)SequelizeConnectionRe…SQLAlchemy IntegrityError — sqlalchemy.exc.IntegrityError: (psycopg2.errors.UniqueViolation) duplicate key value violates unique constraint (Python)SQLAlchemy IntegrityE…SQLAlchemy OperationalError — sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server … failed (Python)SQLAlchemy Operationa…Transient…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.