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.