From: <no...@at...> - 2006-06-29 18:08:15
|
Exception raising : Strange behaviour depending on package names ---------------------------------------------------------------- Key: ANN-382 URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN= -382 Project: Hibernate Annotations Type: Bug Environment: Hibernate's annotations packaged in JBoss EJB 3.0 RC8- FD Microsoft SQL Server 2000 Reporter: Pierre Four=C3=A8s Attachments: BugEJB3.zip As described in hibernate forum (http://forum.hibernate.org/viewtopic.php?t= =3D960763) and discussed with Emmanuel, I encounter a strange behaviour wit= h annotations depending of my package's names. Supposing hibernate load classes by package alphabetical order; if it get t= he "parent" class first all works fine, if it get the "child" class first, = it raise an exception !=20 Here is a subset of my classes, cleaned of getters, setters and all unrelat= ed things, then followed by the exception stack :=20 /////////////////////////////////////////////// package fr.ifis.entity.field.card; import java.io.Serializable; import javax.persistence.Embeddable; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.ManyToOne; import fr.ifis.entity.project.Card; @Entity public class CardField { @Id private PrimaryKey primaryKey =3D new PrimaryKey(); =20 // cardtmp is a trick used in order to wait for http://opensource.atlass= ian.com/projects/hibernate/browse/ANN-381 resolution=20 @ManyToOne private Card cardtmp; @Embeddable private class PrimaryKey implements Serializable { =20 @ManyToOne(optional =3D false) private Card card; =20 @ManyToOne(optional =3D false) private CardKey key; } }=20 /////////////////////////////////////////////// package fr.ifis.entity.field.card; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; @Entity public class CardKey { @Id @GeneratedValue private int id; }=20 /////////////////////////////////////////////// package fr.ifis.entity.project; import java.io.Serializable; import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Embeddable; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.Id; import javax.persistence.ManyToOne; import javax.persistence.OneToMany; import fr.ifis.entity.field.card.CardField; @Entity public class Card { @Id private CardPrimaryKey primaryKey =3D new CardPrimaryKey(); =20 @OneToMany(cascade=3DCascadeType.ALL, fetch=3DFetchType.EAGER, mappedBy= =3D"cardtmp") // private Set<CardField> fields; =20 @Embeddable private class CardPrimaryKey implements Serializable { =20 @ManyToOne(optional =3D false) private Project project; =20 //An other @ManyToOne is also present in the real model //The problem still occurs even when i remove this relation, it was n= o use to kept it for describe the problem } }=20 /////////////////////////////////////////////// package fr.ifis.entity.project; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; @Entity public class Project { @Id @GeneratedValue private int id; }=20 /////////////////////////////////////////////// [java] ERROR 29-06 19:42:18,272 (AbstractController.java:incrementStat= e:350) -Error installing to Start: name=3Dpersistence.units:unitName=3DRef= onte state=3DCreate [java] org.hibernate.MappingException: Foreign key (FK6771BFAA1845E8B:= CardField [])) must have same number of columns as the referenced primary k= ey (Card [project_id]) [java] at org.hibernate.mapping.ForeignKey.alignColumns(ForeignKey.jav= a:90) [java] at org.hibernate.mapping.ForeignKey.alignColumns(ForeignKey.jav= a:73) [java] at org.hibernate.cfg.Configuration.secondPassCompileForeignKeys= (Configuration.java:1182) [java] at org.hibernate.cfg.Configuration.secondPassCompile(Configurat= ion.java:1089) [java] at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(= AnnotationConfiguration.java:302) [java] at org.hibernate.cfg.Configuration.buildMappings(Configuration.= java:1034) [java] at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Config= uration.java:1015) [java] at org.hibernate.ejb.EventListenerConfigurator.configure(EventL= istenerConfigurator.java:154) [java] at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFacto= ry(Ejb3Configuration.java:751) [java] at org.hibernate.ejb.Ejb3Configuration.createContainerEntityMan= agerFactory(Ejb3Configuration.java:350) [java] at org.hibernate.ejb.HibernatePersistence.createContainerEntity= ManagerFactory(HibernatePersistence.java:119) [java] at org.jboss.ejb3.entity.PersistenceUnitDeployment.start(Persis= tenceUnitDeployment.java:264) [java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce= ssorImpl.java:39) [java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe= thodAccessorImpl.java:25) [java] at java.lang.reflect.Method.invoke(Method.java:585) [java] at org.jboss.reflect.plugins.introspection.ReflectionUtils.invo= ke(ReflectionUtils.java:55) [java] at org.jboss.reflect.plugins.introspection.ReflectMethodInfoImp= l.invoke(ReflectMethodInfoImpl.java:107) [java] at org.jboss.joinpoint.plugins.BasicMethodJoinPoint.dispatch(Ba= sicMethodJoinPoint.java:66) [java] at org.jboss.kernel.plugins.dependency.KernelControllerContextA= ctions.dispatchJoinPoint(KernelControllerContextActions.java:100) [java] at org.jboss.kernel.plugins.dependency.KernelControllerContextA= ctions$LifecycleAction.installAction(KernelControllerContextActions.java:58= 2) [java] at org.jboss.kernel.plugins.dependency.KernelControllerContextA= ctions$KernelControllerContextAction.install(KernelControllerContextActions= .java:175) [java] at org.jboss.dependency.plugins.AbstractControllerContextAction= s.install(AbstractControllerContextActions.java:51) [java] at org.jboss.dependency.plugins.AbstractControllerContext.insta= ll(AbstractControllerContext.java:226) [java] at org.jboss.dependency.plugins.AbstractController.install(Abst= ractController.java:593) [java] at org.jboss.dependency.plugins.AbstractController.incrementSta= te(AbstractController.java:346) [java] at org.jboss.dependency.plugins.AbstractController.resolveConte= xts(AbstractController.java:438) [java] at org.jboss.dependency.plugins.AbstractController.resolveConte= xts(AbstractController.java:379) [java] at org.jboss.dependency.plugins.AbstractController.install(Abst= ractController.java:225) [java] at org.jboss.dependency.plugins.AbstractController.install(Abst= ractController.java:151) [java] at org.jboss.kernel.plugins.dependency.AbstractKernelController= .install(AbstractKernelController.java:79) [java] at org.jboss.kernel.plugins.dependency.AbstractKernelController= .install(AbstractKernelController.java:73) [java] at org.jboss.ejb3.MCKernelAbstraction.install(MCKernelAbstracti= on.java:91) [java] at org.jboss.ejb3.Ejb3Deployment.startPersistenceUnits(Ejb3Depl= oyment.java:626) [java] at org.jboss.ejb3.Ejb3Deployment.start(Ejb3Deployment.java:475) [java] at org.jboss.ejb3.embedded.EJB3StandaloneDeployer.start(EJB3Sta= ndaloneDeployer.java:460) [java] at org.jboss.ejb3.embedded.EJB3StandaloneBootstrap.scanClasspat= h(EJB3StandaloneBootstrap.java:291) [java] at fr.ifis.Main.main(Unknown Source) /////////////////////////////////////////////// Indeed, depending on the package names I get or not an excpetion ! It doesn't work with the package fr.ifis.entity.project but if I rename the= package in fr.ifis.entity.aproject and then move it "before" the field.car= d package, all works fine. In order to facilitate the identification of the problem, I also include as= attachement the eclipse project of this problem repport. In order to keep reasonable the size of the attachement, I did not included= the libraries nor the configuration files for launch ejb3-embedded. Thoses= files are issued from the project simple-deployment included in JBoss EJB = 3.0 RC8-FD. The only change i've done was to specify in embedded-jboss-bean= s.xml the properties of my database. Regards, Pierre. --=20 This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators= .jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |