title: OneToMany, ManyToOne why value of parent in children is null?
body: <p>I read similar questions, but still have problem.</p>
  
  <p>Configuration info:
  Hibernate 3.5.1 </p>
  
  <p>Parent class Question:</p>
  
  <pre><code>@Entity
  public class Question implements Serializable {
  
      private static final long serialVersionUID = 1L;
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      @Column(name="questionId")
      private long id;
      private String title;
      private String description;
  
      @OneToMany(cascade=CascadeType.ALL, mappedBy="question")
      private Set&lt;Vote&gt; votes;
  
      public void addVote(Vote vote){
          if(votes==null)
              votes = new HashSet&lt;Vote&gt;();
          getVotes().add(vote);
      }
  
  }
  </code></pre>
  
  <p>Child class Vote:</p>
  
  <pre><code>@Entity
  public class Vote implements Serializable {
      private static final long serialVersionUID = 1L;
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      @Column(name="voteId")
      private long id;
  
      private transient InetAddress address;
  
      @ManyToOne
      @JoinColumn(name="questionId")
      private Question question;
  
      @Enumerated(EnumType.STRING)
      private Mode mode;
  
  // ...
  }
  </code></pre>
  
  <p>And finally very simple test:</p>
  
  <pre><code>@Test
  public void testSaveOrUpdate() {
  Vote vote1 = new Vote();
      vote1.setAddress(InetAddress.getLocalHost());
      vote1.setMode(Mode.HIM);
      question = new Question();
      question.setTitle("test?");
      question.setDescription("test");
      question.addVote(vote1);
  
      question2 = questionDao.saveOrUpdate(question);
      assertNotNull(question2);
      Set&lt;Vote&gt; votes = question.getVotes();
      assertEquals(votes.size(), 1);
      for(Vote vote:votes)
          assertNotNull(vote.getQuestion());
  }
  </code></pre>
  
  <p>test fail because <em>vote.getQuestion()</em> return null. When I check in DB there are null in <em>questionId</em> column. My question is what I should do to have reference to <em>question</em> in <em>vote</em> from <em>votes</em>? there is something wrong with mapping but i have no idea what.</p>