简体   繁体   English

如何删除“空ID…条目(在发生异常后不要刷新会话)”

[英]how to remove “null id …entry (don't flush the Session after an exception occurs)”

hello،I am web developer in php and recently migrateto javaEE.I create to table in mysql. 您好,我是php的Web开发人员,最近迁移到javaEE。我在mysql中创建了表。 this is 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;

. . .

Try generating your ID automatically and see if u face the same problem 尝试自动生成您的ID,看看您是否遇到相同的问题

 @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;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Hibernate AssertionFailure:条目中的id为null(发生异常后不要刷新Session) - Hibernate AssertionFailure: null id in entry (don't flush the Session after an exception occurs) Spring JPA/Hibernate org.hibernate.AssertionFailure: null id in Entity(异常发生后不刷新Session) - Spring JPA/Hibernate org.hibernate.AssertionFailure: null id in Entity (don't flush the Session after an exception occurs) session.flush()导致Hibernate中的Null Pointer异常 - session.flush() caused Null Pointer Exception in Hibernate 调用commit()或flush()之后如何处理异常 - How to handle exception after call commit() or flush() 不知道为什么会出现数组越界异常 - Don't know why the array out of bounds exception occurs 在session.flush之后,Hibernate @BatchSize无法按预期工作 - Hibernate @BatchSize doesn't work as expected after session.flush servlet中是否发生了空指针异常? - Null Pointer Exception occurs in servlet? 每当我在 java 中运行插入排序程序时,都会发生异常.. 但我不知道为什么 - Whenever I run the insertion sort program in java, exception occurs .. but i don't know why 发生此异常后,所有其他请求都失败“具有相同标识符值的另一个对象已与会话关联” - After this exception occurs all other requests are failing “a different object with the same identifier value was already associated with the session” 如果会话处于活动状态,如何使该应用程序在浏览器重启后不要求我重新登录 - How to make that app don't ask me relogin after browser restart if session alive
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM