你好,我是php的web开发人员,最近是migto到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;
。 。
答案 0 :(得分:1)
尝试自动生成您的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;