-->
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.  [ 1 post ] 
Author Message
 Post subject: has the wrong number of column... error message
PostPosted: Thu Jun 03, 2010 1:08 pm 
Newbie

Joined: Sun Apr 06, 2008 8:49 am
Posts: 3
Firstly, I've posted this in the general forum as I am not sure if this issue is related to hibernate core or envers. Mods, please move if needed!

I have a Hibernate 3.5/JPA 2 application with one central class called Person, and several related collections. I've distilled the application down to 2 classes for an example:

Person.java

Code:
public class Person(){

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "Id")
private int id;

...... More vars...

@Fetch(FetchMode.SELECT)
@Sort(type = SortType.NATURAL)
@OneToMany(mappedBy = "person", fetch = FetchType.LAZY)
private SortedSet<Appointment> appointments;

...... Getters/Setters etc...

}


Appointment.java

Code:
public class Appointment(){

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "Id")
private int id;

...... More vars...

@NotNull
@ManyToOne
@JoinColumn(name = "fkPerson")
private Person person;

...... Getters/Setters etc...

}


This all works as expected when envers is not involved. However, when I add the following lines to my persistence.xml:

Code:
         <property name="hibernate.ejb.event.post-insert"
             value="org.hibernate.ejb.event.EJB3PostInsertEventListener,org.hibernate.envers.event.AuditEventListener" />
   <property name="hibernate.ejb.event.post-update"
             value="org.hibernate.ejb.event.EJB3PostUpdateEventListener,org.hibernate.envers.event.AuditEventListener" />
   <property name="hibernate.ejb.event.post-delete"
             value="org.hibernate.ejb.event.EJB3PostDeleteEventListener,org.hibernate.envers.event.AuditEventListener" />
   <property name="hibernate.ejb.event.pre-collection-update"
             value="org.hibernate.envers.event.AuditEventListener" />
   <property name="hibernate.ejb.event.pre-collection-remove"
             value="org.hibernate.envers.event.AuditEventListener" />
   <property name="hibernate.ejb.event.post-collection-recreate"
             value="org.hibernate.envers.event.AuditEventListener" />


I get the following statck trace on application start:

Code:
Caused by: org.hibernate.AnnotationException: A Foreign key refering org.xxx.ips.model.Person from org.xxx.ips.model.Appointment has the wrong number of column. should be 2
   at org.hibernate.cfg.annotations.TableBinder.bindFk(TableBinder.java:419)
   at org.hibernate.cfg.ToOneFkSecondPass.doSecondPass(ToOneFkSecondPass.java:111)
   at org.hibernate.cfg.AnnotationConfiguration.processEndOfQueue(AnnotationConfiguration.java:536)
   at org.hibernate.cfg.AnnotationConfiguration.processFkSecondPassInOrder(AnnotationConfiguration.java:518)
   at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:373)
   at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1206)
   at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1416)
   at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:193)
   at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:1044)
   at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:640)
   at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:72)
   at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:225)
   at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:308)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1460)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1400)
   ... 54 more


I'm thinking that this might not be directly related to Envers as the error occurs even if I don't add any @auditable annotations to my classes. Does anyone have some ideas as to what's going on here?


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

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.