title: Insert data into table using Hibernate
body: <p>I'm new to Hibernate. I want to insert data into this hibernate entity:</p>
  
  <pre><code>@Entity
  public class Invitation implements Serializable
  {
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private Long id;
  
      @Column(name = "invited_on")
      @Temporal(TemporalType.TIMESTAMP)
      private Date invitedOn;
  
      @Column(name = "invited_email")
      private String invitedEmail;
  
      @Column(name = "invitation_msg")
      private String invitationMessage;
  
      private Boolean status; //true:accepted || false:pending
  
      @ManyToOne
      @JoinColumn(name = "sent_by")
      private Person inviter;
  
  // getters and setters
  }
  </code></pre>
  
  <p>I tested this <strong>code</strong>:</p>
  
  <pre><code>public void insert()
  {
      Query query = session.createQuery("insert into Invitation(invited_on, invited_email, invitation_msg, sent_by)");
      int result = query.executeUpdate();
  }
  </code></pre>
  
  <p>What is the proper way to insert data? How I should create session Object?</p>