-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Newbie - A Foreign key refering error with composite key
PostPosted: Sun Oct 23, 2005 9:42 pm 
Newbie

Joined: Sun Oct 23, 2005 9:35 pm
Posts: 1
Location: Australia
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();
   }
.....


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 24, 2005 5:39 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Something points to TréansactionCMP (an association) nad has the wrong column number

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.