![](/img/trans.png)
[英]Hibernate AssertionFailure: null id in entry (don't flush the Session after an exception occurs)
[英]how to remove “null id …entry (don't flush the Session after an exception occurs)”
您好,我是php的Web開發人員,最近遷移到javaEE。我在mysql中創建了表。 這是頭等艙:
@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;
。 。 。 這是我的第二堂課:
@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;
。 。 。
嘗試自動生成您的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.