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.
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
- Save the referenced entity first
- Add cascade on the owning relation
- Load existing entities with getReferenceById instead of new
Detailed fix by platform
Java
@OneToMany(mappedBy = "order", cascade = CascadeType.ALL)
How to diagnose
- Reference — Which entity is transient?
- Cascade — Configured on that relation?
🧠 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.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026