How to delete the entry "null id ..." (do not clear the session after an exception is thrown) "

Hi I am a web developer in php and recently migrateto javaEE.I create a table in mysql. this is the first class:

@Entity
@Table(name = "first")
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)   
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE,     inclu`enter code here`de = "all")
public class first extends second {

@OneToOne(cascade = CascadeType.ALL)
private second A;

      

... ., and this is my second class:

    @Entity
    @Table(name = "second", uniqueConstraints =
    @UniqueConstraint(columnNames = {"feildone", "feildtwo"}))
    public class second implements Serializable {
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "first")
    public static final String FindOne = "findOne";
    @Id
    @GeneratedValue
    Integer id;
    private String feildtwo;
    private String feildone;
    @Temporal(javax.persistence.TemporalType.DATE)
    private Date createTime;
    @OneToMany(cascade = CascadeType.ALL)
    public List<Progress> progress = new ArrayList<>();
    private Integer num;

      

... ,.

0


source to share


1 answer


Try to generate your ID automatically and see if you have the same problem.



 @Entity
        @Table(name = "second", uniqueConstraints =
        @UniqueConstraint(columnNames = {"feildone", "feildtwo"}))
        public class second implements Serializable {
        @OneToOne(cascade = CascadeType.ALL, mappedBy = "first")
        public static final String FindOne = "findOne";
        @Id
        @GeneratedValue(strategy = GenerationType.AUTO) // try to use auto generate id guess this might help
        Integer id;
        private String feildtwo;
        private String feildone;
        @Temporal(javax.persistence.TemporalType.DATE)
        private Date createTime;
        @OneToMany(cascade = CascadeType.ALL)
        public List<Progress> progress = new ArrayList<>();
        private Integer num;

      

+1


source







All Articles