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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:00:40+00:00 2026-06-13T23:00:40+00:00

I’ve inherited a hibernate application and I’ve run into issues. It seems that the

  • 0

I’ve inherited a hibernate application and I’ve run into issues. It seems that the code does not save the child in a One-To-Many relationship. It’s bidirectional, but on save of parent object, it doesn’t seem to save the child.

The Question class is the parent in this case.

// Question.java
@Entity
@SequenceGenerator(name = "question_sequence", sequenceName = "seq_question", allocationSize = 1000)
@Table(name = "question")
public class Question {
   protected Long questionId;
   protected Set<AnswerValue> answerValues;

   public TurkQuestion(){}

   public TurkQuestion(Long questionId){
      this.questionId = questionId;
   }

   @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "question_sequence")
   @Column(name = "question_id")
   public Long getQuestionId(){
      return questionId;
   }

   @OneToMany(fetch = FetchType.EAGER)
   @JoinColumn(name = "question_id",referencedColumnName="question_id")
   public Set<AnswerValue> getAnswerValues(){
      return answerValues;
   }

   public void setQuestionId(Long questionId){
      this.questionId = questionId;
   }

   public void setAnswerValues(Set<AnswerValue> answerValues){
      this.answerValues = answerValues;
   }
}

AnswerValue is the child class.

// AnswerValue.java
@Entity
@SequenceGenerator(name = "answer_value_sequence", sequenceName = "seq_answer_value", allocationSize = 1)
@Table(name = "answer_value")
public class AnswerValue {
    protected Long answerValueId;
    protected Question question;
    protected String answerValue;

    public AnswerValue(){}

    public AnswerValue(Long answerValueId, Long questionId, String answerValue){
       this.answerValueId = answerValueId;
       this.question = new Question(questionId);
       this.answerValue = answerValue;
    }

    @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "answer_value_sequence")
    @Column(name = "answer_value_id")
    public Long getAnswerValueId(){
       return answerValueId;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "question_id", nullable = false )
    public Question getQuestion(){
       return question;
    }

    @Column(name = "answer_value")
    public String getAnswerValue(){
       return answerValue;
    }

    public void setAnswerValueId(Long answerValueId){
       this.answerValueId = answerValueId;
    }

    public void setQuestion(Question question){
       this.question = question;
    }

    public void setAnswerValue(){
       this.answerValue = answerValue;
    }
}

And the DAO:

// QuestionDao.java
public class QuestionDao {
   public void saveOrUpdateAll(List<Question> list){
      getHibernateTemplate().saveOrUpdateAll(list);
   }
}

It seems when I call saveOrUpdateAll, Question is saved, but the AnswerValue that are children of the Question object are not.

Any suggestions?

  • 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-13T23:00:41+00:00Added an answer on June 13, 2026 at 11:00 pm

    you need to do it manually or add the cascade property to your annotation, i.e. Hibernate: Cascade Type

    or Hibernate: How use cascade in annotation?

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace

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.