我有兩個類這樣JPA與@ManyToOne
package models;
import java.util.*;
import javax.persistence.*;
import play.db.jpa.*;
@Entity
@Table(name = "commitment_type_value")
public class CommittmentTypeValue extends Model{
@Id
@Column(name = "id", nullable = false)
public Long id;
@Column(name = "value", nullable = true)
public String type;
@ManyToOne
@JoinColumn(name="commitment_type_id")
public CommitementType commitmentType;
public CommittmentTypeValue(){
}
}
-------------
package models;
import java.util.*;
import javax.persistence.*;
import play.db.jpa.*;
/**
*
* @author hatem
*/
@Entity
@Table(name = "commitment_type")
public class CommitementType extends Model{
@Id
@Column(name = "id", nullable = false)
public Long id;
@Column(name = "type", nullable = true)
public String type;
@OneToMany(fetch=FetchType.LAZY, cascade = CascadeType.ALL, mappedBy="commitmentType")
public List<CommittmentTypeValue> commitmentTypeValues;
public CommitementType(){
}
}
當我執行我的應用程序,出現這樣的問題:發生
一個JPA錯誤(無法建立EntityManagerFactory的):一個外國 鍵引用Models.CommitementType.CommittmentTypeValue 的列數錯誤。應該是2
請,可以任何人告訴我什麼是錯的?
我不明白,我不是還沒有在創建數據庫中的表,它與遊戲的框架內聯網應用,如果我跑我的應用程序,表格自動創建 –
是üR右,他要利用生成的實體類。 – vels4j