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 8296499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T15:02:10+00:00 2026-06-08T15:02:10+00:00

I have an entity Quest which contains many Task s: @Entity public class Quest

  • 0

I have an entity Quest which contains many Tasks:

@Entity
public class Quest {

    @OneToMany(orphanRemoval=true,cascade=CascadeType.ALL)
    @JoinColumn(name="quest_id")
    @MapKey(name="taskName")
    private Map<String, Task> tasks = Maps.createHash();

    @ElementCollection
    @OrderColumn
    private Set<String> completedTasks;

@Entity
public class Task implements Serializable {

    @ManyToOne(optional=false)
    @JoinColumn(name="quest_id")
    private Quest quest;

    @Column(nullable=false,updatable=false,length=50)
    private String taskName;

Now when I do this:

// store the task as completed
quest.getCompletedTasks().add(taskName); // set
// remove the task entity
quest.getTasks().remove(taskName); // map

Hibernate attempts to perform the nonsensical query, and fails:

update Task set quest_id=null where quest_id='77149'

This appears to break the connection between the quest and all its tasks (WHERE quest_id = ...), which seems to me like something to do when the quest itself is removed (which it isn’t). In any case, it shouldn’t null anything, it should just DELETE the Task entirely.

What is wrong?

  • 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-06-08T15:02:12+00:00Added an answer on June 8, 2026 at 3:02 pm

    The update is not nonsensical: you remove the task from quest‘s list, so hibernate deletes the connection between the task and the quest.

    Update:
    I just noticed that you have @JoinColumn and @OneToMany on the same field. I think you should do this instead (depending on which hibernate version you use):

    @OneToMany(mappedBy="quest", orphanRemoval=true,cascade=CascadeType.ALL)
    @MapKey(name="taskName")
    private Map<String, Task> tasks = Maps.createHash();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My entities: @Entity public class User implements Serializable { @OneToMany(orphanRemoval=true,cascade=CascadeType.ALL) @JoinColumn(name=_user_id) @MapKey(name=quest) private Map<String,
Let's say we have: @Entity public class Order { @Id private int id; @OneToMany(mappedBy=order)
I have an Entity which holds a collection of OtherEntity in a many-to-many style
I have entity Territory class Territory { public int Id {get;set;} public string Title
Hibernate allows you to just say .id. Let's say I have: @Entity public class
I have entity class: public class Project { public virtual int Id { get;
I have entity objects: @Entity public class Tag { @Id private Long id; @Transient
I have entity called Customer and it has three properties: public class Customer {
Technology: Hibernate 3.0 Suppose i have Entity class Company @Entity @Table(name=tbl_companies) public class Company
I have entity class which is used to model a weather station, and it

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.