2
我有以下錯誤的問題:休眠雙向多對一
Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/library.xml]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: A Foreign key refering tv.mirada.connect.cashless.parking.model.PaymentInterface from tv.mirada.connect.cashless.parking.model.Merchant has the wrong number of column. should be 0
我花了大約一天尋找答案,並試圖東西,沒有運氣。我實際上並不需要雙向訪問,我只需要能夠從payment_interface獲得商家表格行,但是包含雙向表單比試圖從單向到單向更簡單。
我使用的表格是商家表和付款接口表。我意識到我可以讓商戶表直接引用節點表,但商家表在支付界面中具有信息的擴展,因此以這種方式映射它是更有意義的。
@Entity
@Cache(usage = CacheConcurrencyStrategy.READ_ONLY)
@Table(name = "park_merchant")
public class Merchant implements java.io.Serializable {
@Id
@GeneratedValue
@Column(name="id", unique=true, nullable=false)
private Integer id;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name="payment_interface_node_id", nullable = false)
private PaymentInterface paymentInterface;
@Entity
@Table(name = "park_payment_interface", uniqueConstraints = @UniqueConstraint(columnNames = "name"))
public class PaymentInterface implements java.io.Serializable {
@Id
@OneToOne(fetch=FetchType.LAZY, cascade=CascadeType.ALL)
@JoinColumn(name = "node_id", unique = true, nullable = false)
private Node node;
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "paymentInterface")
private Set<Merchant> merchants = new HashSet<Merchant>(0);
希望我只是想念一些簡單的東西。