[英]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.