-->
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: AnnotationException: : wrong number of column
PostPosted: Sun Jun 24, 2012 7:00 am 
Newbie

Joined: Thu Jul 28, 2011 2:54 pm
Posts: 12
Hi,

the following exception happens during hibernate initialisation:

Quote:
Initial SessionFactory creation failed.org.hibernate.AnnotationException: A Foreign key refering com.stockdomain.domain.Future from com.stockdomain.domain.BrokerRealTimeFuture has the wrong number of column. should be 2


I don't find the reason why hibernate says that the number of columns should be 2...the Primary key in table future has one column.

Code:
@Entity
@IdClass(com.stockdomain.domain.BrokerRealTimeFutureCK.class)
public class BrokerRealTimeFuture {

   @Id
   private Integer brokerid;
   @Id
   private Integer futureid;
   @Id
   private Integer tapatternid;
   @Id
   private Integer retrievalintervalseconds;

   @ManyToOne(fetch = FetchType.EAGER)
   @JoinColumn(name = "brokerid", nullable = false, updatable = false, insertable = false)
   private Broker broker;

   @ManyToOne(fetch = FetchType.EAGER)
   @JoinColumn(name = "futureid", nullable = false, updatable = false, insertable = false)
   private Future future;

   @ManyToOne(fetch = FetchType.EAGER)
   @JoinColumn(name = "tapatternid", nullable = false, updatable = false, insertable = false)
   private TaPattern taPattern;
...



Code:
@Embeddable
public class BrokerRealTimeFutureCK implements Serializable {

   private static final long serialVersionUID = -7826108862419808948L;

   private Integer brokerid;
   private Integer futureid;
   private Integer tapatternid;
   private Integer retrievalintervalseconds;
...



Code:
@Entity
@Table(name = "future")
public class Future extends BaseEntity implements Security {

   private static final long serialVersionUID = -4018832656660913980L;
   
   @Id
   @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "future_sequence_generator")
   @SequenceGenerator(name = "future_sequence_generator", sequenceName = "future_sequence_table", allocationSize = 1)
   private Integer id;
   @Column
   private String code;
   @Column
   private Date expirationdate;
   @Column
   private String name;
   @Column
   private String isin;
   @Column
   private Integer exchangeid;
   @Column
   private Integer countryid;
   @Column
   private String subsectorcode;
   @Column
   private String liquid;
   @Column
   private Boolean active;
   @Column
   private String ibcode;
...


Part of pom.xml :

Code:
     <properties>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      <spring.version>3.0.7.RELEASE</spring.version>
        <hibernate.version>3.6.7.Final</hibernate.version>      
      <java.version>1.6</java.version>
   </properties>

     <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>${hibernate.version}</version>
        <exclusions>
           <exclusion>
              <artifactId>slf4j-api</artifactId>
              <groupId>org.slf4j</groupId>
           </exclusion>
        </exclusions>
     </dependency>


Many thanks for help.


Top
 Profile  
 
 Post subject: Re: AnnotationException: : wrong number of column
PostPosted: Tue Jun 26, 2012 3:43 pm 
Newbie

Joined: Thu Jul 28, 2011 2:54 pm
Posts: 12
Found the reason.
The class I'm extending "BaseEntity" also has an id. So, the duplication causes the exception.


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.