i'm getting org.hibernate.AnnotationException: A Foreign key refering com.meerkat.jfr.par.TransactionCMP has the wrong number of column. should be 4
I am using Jboss 4.0.3. The examples I have based this on are a little "loose" so i made the odd assumption.
I have tried Overriding attributes etc but still no luck.
thanks
Andrew
PK class
Code:
package com.meerkat.jfr.par;
import java.util.Date;
import javax.persistence.Embeddable;
@Embeddable
public class TransactionPK implements java.io.Serializable {
private long id;
private String store;
private String register;
private Date txndatetime;
public TransactionPK()
{
}
public TransactionPK(long id, String store, String register, Date txndate)
{
this.id = id;
this.store = store;
this.register = register;
this.txndatetime = txndate;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getRegister() {
return register;
}
public void setRegister(String register) {
this.register = register;
}
public String getStore() {
return store;
}
public void setStore(String store) {
this.store = store;
}
public Date getTxndatetime() {
return txndatetime;
}
public void setTxndatetime(Date txndatetime) {
this.txndatetime = txndatetime;
}
public int hashCode()
{
return (int) id + store.hashCode()+ register.hashCode()+txndatetime.hashCode();
}
public boolean equals(Object obj)
{
if (obj == this)
return true;
if (!(obj instanceof TransactionPK) ||(obj == null))
return false;
TransactionPK pk = (TransactionPK) obj;
return pk.id == id && pk.store.equalsIgnoreCase(store)
&& pk.register.equalsIgnoreCase(register) && pk.txndatetime.equals(txndatetime);
}
}
Code:
public class TransactionCMP implements java.io.Serializable
{
private CustomerCMP customer;
private TransactionPK pk;
private String salesperson;
private Integer receiptno;
private String txndate;
private String txntime;
private String txntype;
private Double total;
private Double taxamount;
private Double balance;
private Double totaldiscounts;
private Double roundingapplied;
private Boolean suspended;
private Boolean voided;
private Boolean postvoided;
private List<TenderItemCMP> TenderList;
private List<LineItemCMP> LineList;
private String[] txntypes;
@EmbeddedId
public TransactionPK getPk()
{
return pk;
}
public void setPk(TransactionPK pk)
{
this.pk = pk;
}
@Transient
public String getStore() {
return pk.getStore();
}
.....