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

  • SEARCH
  • Home
  • 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 7571975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:48:17+00:00 2026-05-30T15:48:17+00:00

I have the below unidirectional Many To One mapping @Entity public class Item implements

  • 0

I have the below unidirectional Many To One mapping

@Entity
public class Item implements Serializable {
    private Integer id;
    private Double amount;
        private Country origin;

    @ManyToOne(optional=true)
    @JoinColumn
    public Country getOrigin() {
        return this.origin;
    }
}

@Entity
public class Country implements Serializable{

    private String code;
    private String desc;
}

Let say the relationship is optional so I am trying to remove the relation by updating it to null using code below

Country country = null;
//item is detached
item.setOrigin(country);
em.merge(item);

But the result turns out to be relationship is not removed.
However, this code works fine if country is not null and the system can update the relationship in DB.
It just simply ignore the field if it’s null.
Can someone points out what setting can be changed in order to achieve my desired result?

P.S. Please be reminded that I am not wanting to delete the entity Country, but just remove the relationship between them.

  • 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-30T15:48:18+00:00Added an answer on May 30, 2026 at 3:48 pm

    Thanks all it’s a mistaken question. It actually works.

    There’s just some client side issue submitting wrong data to it.

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

Sidebar

Related Questions

I have an Class with a unidirectional one to many relationship as follows: public
I have below code in html. <li class=selected runat=server id=lihome><a href=/ISS/home.aspx title=Home><span>Home</span></a></li> Now I
I have below XAML code : <Window x:Class=WpfApplication1.Window1 xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml DataContext={Binding RelativeSource={RelativeSource Self}} WindowStartupLocation=CenterScreen
i am actually reading Doctrine Reference: One to Many, Unidirectional with Join table .
i have below code snippet in my legacy project DetachedCriteria subCriteria = DetachedCriteria.forClass(Employee.class); subCriteria.setProjection(Projections.distinct(Property.forName
I have below html <table class=Newuser cellspacing=0 cellpadding=0 border=0 id=ctl00_ContentPlaceHolder2_CreateUserWizard1> <tr> <td> <table> <tr>
I have below HTML code <table class=innerGridTable cellpadding=0 cellspacing=0 width=100%> <tr id=trMain> <td> <asp:Button
I have below classes. How can I write mapping document for MainBranch.Id column. I
I have below code written with Eclipse ide: public interface X { final public
I have Below code One is bindable to my User Repository and another for

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.