1 Reply Latest reply on Jan 3, 2008 7:12 AM by jBossTester jBossTester

    broken column mapping exception on @OneToOne mapping

    Gus Gu Expert

      Hi all,

      I got an exception on my entity mappings. The codes are as follows:

      table test (
       id
       name
      )
      
      table deleted_test (
       test_id
       person_id
       deleted_date
      )
      
      @Embeddable
      class PK {
       int test_id;
       int person_id;
       ...
      }
      
      @Entity
      @Table(name="deleted_test")
      class DeletedTest {
       PK pk;
       Test test;
       Person person;
       ...
       @EmbeddedId
       public PK getPk(){
       return pk;
       }
       ...setPk...
      
       @OneToOne(cascade=CascadeType.ALL,fetch=FetchType.EAGER)
       @JoinColumn(name="Test_ID", nullable = false, insertable = false, updatable = false)
       public Test getTest() {
       return test;
       }
       public void setTest(Test Test) {
       this.test = test;
       }
      
       @ManyToOne
       @JoinColumn(name="PERSON_ID", nullable=false, insertable = false, updatable = false)
       public Person getPerson() {
       return person;
       }
      
       public void setPerson(Person person) {
       this.person = person;
       }
      ...
      }

      When I run it on JBoss4.0.4GA and EJB3 RC8, I always got the following exceptions:
      org.hibernate.MappingException: broken column mapping for: test.id of: DeletedTest
       at org.hibernate.persister.entity.AbstractPropertyMapping.initPropertyPaths(AbstractPropertyMapping.java:122)
       at org.hibernate.persister.entity.AbstractPropertyMapping.initIdentifierPropertyPaths(AbstractPropertyMapping.java:176)
       at org.hibernate.persister.entity.AbstractPropertyMapping.initPropertyPaths(AbstractPropertyMapping.java:160)
       at org.hibernate.persister.entity.AbstractEntityPersister.initOrdinaryPropertyPaths(AbstractEntityPersister.java:1628)
       at org.hibernate.persister.entity.AbstractEntityPersister.initPropertyPaths(AbstractEntityPersister.java:1656)
       at org.hibernate.persister.entity.AbstractEntityPersister.postConstruct(AbstractEntityPersister.java:2699)
       at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:386)
       at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
       at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:223)
       at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1213)
       at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:631)
       at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:760)
       at org.hibernate.ejb.Ejb3Configuration.createContainerEntityManagerFactory(Ejb3Configuration.java:350)
       at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:119)
       at org.jboss.ejb3.entity.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:264)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.ejb3.ServiceDelegateWrapper.startService(ServiceDelegateWrapper.java:99)
       at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
       at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
       at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
      

      However,if I changed the test mapping to ManyToOne from OneToOne, no exceptions occured. I want to know the OneToOne mapping here is wrong or not. I appreciate any directions. Thank you in advance.
      GUS