6 Replies Latest reply on Feb 25, 2008 6:58 PM by dustismo

    How to insert data more than one time for a single entity ?

    sart

      Hello!


      I found that i can't insert data more than one time with persist(). I know that every time we want to make persist() we need to create new entity instance. But with seam i use @In to  inject my entity, so what should i do to solve this problem ?


      This is my entity bean..


      package com.st.st;
      
      import java.util.Date;
      import javax.persistence.Column;
      import javax.persistence.Entity;
      import javax.persistence.GeneratedValue;
      import static javax.persistence.GenerationType.IDENTITY;
      import javax.persistence.Id;
      import javax.persistence.Table;
      import org.hibernate.validator.NotNull;
      import org.jboss.seam.annotations.Name;
      
      
      @Entity
      @Table(name = "schedule", catalog = "seamtest")
      @Name("schedule")
      public class Schedule implements java.io.Serializable {
      
           private Integer scheduleId;
           private float value;
           private Date date;
      
           public Schedule() {
           }
      
           public Schedule(float value, Date date) {
                this.value = value;
                this.date = date;
           }
      
           @Id
           @GeneratedValue(strategy = IDENTITY)
           @Column(name = "schedule_id", unique = true, nullable = false)
           public Integer getScheduleId() {
                return this.scheduleId;
           }
      
           public void setScheduleId(Integer scheduleId) {
                this.scheduleId = scheduleId;
           }
      
           @Column(name = "value", nullable = false, precision = 12, scale = 0)
           @NotNull
           public float getValue() {
                return this.value;
           }
      
           public void setValue(float value) {
                this.value = value;
           }
      
           @Column(name = "date", nullable = false, length = 0)
           @NotNull
           public Date getDate() {
                return this.date;
           }
      
           public void setDate(Date date) {
                this.date = date;
           }
      
      }