Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 449389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T21:45:53+00:00 2026-05-12T21:45:53+00:00

I have an object Instance with another object Course inside. When trying to persist

  • 0

I have an object “Instance” with another object “Course” inside. When trying to persist a new Instance object, I get the following error if Course is null:

java.lang.IllegalStateException: During synchronization a new object was found through a relationship that was not marked cascade PERSIST: null

Here is my annotation for course:

@OneToOne(cascade = CascadeType.REFRESH,optional=true)
    public Course getCourse() {
        return course;
    }

I don’t see why it’s trying to persist something that’s null. If it’s null, it should just leave that field null in the database right?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T21:45:53+00:00Added an answer on May 12, 2026 at 9:45 pm

    I don’t see why it’s trying to persist something that’s null. If it’s null, it should just leave that field null in the database right?

    By default, TopLink JPA assumes that all the fields of an entity are persistent. If you want to specify a field or property of an entity that is not persistent, you need to mark it with @Transient (but this is not what you want here).

    So, to me, this error is the result of not having specified the proper Cascade type for the OneToOne end of the relation in the Instance Entity. I can’t say why you’re not using ALL but you need at least to add PERSIST.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 217k
  • Answers 217k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can get latest source code from the JDK7 repository.… May 12, 2026 at 11:23 pm
  • Editorial Team
    Editorial Team added an answer If it returns null, it means that your Setup didn't… May 12, 2026 at 11:23 pm
  • Editorial Team
    Editorial Team added an answer In the end I decided to just draw "cursor" objects… May 12, 2026 at 11:23 pm

Related Questions

In ruby I want to do roughly the following and have it print out
I've got a model for Orders in a webshop application, with an auto-incrementing primary
Ok, the short version is that I have a Linq entity from a LinqDataSourceUpdateEventArgs
This is somewhat related to another question that I've asked that I've pretty much

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.