1 Reply Latest reply on Dec 30, 2005 9:09 PM by Emmanuel Bernard

    OneToOne problem

    Alvaro Martinez Newbie

      Hi, folks

      Currently and for this case I have the following configuration, to be run under : JBoss.4.0.3 Sp1 and the EJB3 release coming with this version of JBoss:

      This is the root class

      @Entity
      @Table( name="cdmn_facturas", schema= "CellDom" )
      @Inheritance(strategy=InheritanceType.JOINED, discriminatorValue = "OFactura", discriminatorType=DiscriminatorType.STRING)
      @DiscriminatorColumn(name="ObjClass")
      public class OFactura implements Serializable
      {
       protected String FactId;
      
       @Id(generate=GeneratorType.NONE)
       @Column( name="FactId", nullable=false )
       public String getFactId()
       {
       return FactId;
       }
      
       ....
      
      }
      


      This is the sublcass involved in the problem

      @Entity
      @Table( name="cdmn_FacturasCompra", schema= "CellDom" )
      @Inheritance(discriminatorValue = "OFacturaCompra")
      @PrimaryKeyJoinColumn(name = "FactId", referencedColumnName="FactId" )
      public class OFacturaCompra extends OFactura implements Serializable
      {
       protected ORemision Remision;
       ....
      
       @OneToOne( targetEntity=ORemision.class,
      fetch=EAGER,
      cascade=CascadeType.ALL)
       @JoinColumn( name="RemId", referencedColumnName="RemId" )
       public ORemision getRemision()
       {
       return Remision;
       }
      
       public void setRemision( ORemision remision )
       {
       this.Remision = remision;
       }
      
       ....
      }
      


      and this is the associated class involved in the problem:

      @Entity
      @Table(name="cdmn_Remisiones", schema= "CellDom")
      public class ORemision extends CEJB3Validator implements Serializable
      {
      
       private String RemId;
       private OFacturaCompra fact;
      
       ....
      
       @Id(generate=GeneratorType.NONE)
       @Column( name="RemId", nullable=false )
       public String getRemId()
       {
       return RemId;
       }
      
       ...
       @OneToOne(targetEntity=OFacturaCompra.class, mappedBy="Remision", fetch=EAGER )
       public OFacturaCompra getFact()
       {
       return fact;
       }
      
       public void setFact(OFacturaCompra factNo)
       {
       this.fact = factNo;
       }
      }
      


      well this configuration at deploy stage posts the following exception:


      10:03:39,500 WARN [ServiceController] Problem creating service jboss.j2ee:service=EJB3,module=XCellDomain.par
      java.lang.NullPointerException
      at org.hibernate.util.StringHelper.qualify(StringHelper.java:264)
      at org.hibernate.cfg.ToOneMappedBySecondPass.doSecondPass(ToOneMappedBySecondPass.java:38)
      at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1023)
      at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:218)
      at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:988)
      at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:607)
      at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:75)
      at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:473)
      at org.hibernate.ejb.Ejb3Configuration.createContainerEntityManagerFactory(Ejb3Configuration.java:202)
      at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:78)
      at org.jboss.ejb3.Ejb3Deployment.initializeManagedEntityManagerFactory(Ejb3Deployment.java:512)
      at org.jboss.ejb3.Ejb3Deployment.create(Ejb3Deployment.java:253)
      at org.jboss.ejb3.Ejb3JmxDeployment.create(Ejb3JmxDeployment.java:230)
      at org.jboss.ejb3.Ejb3Module.createService(Ejb3Module.java:34)
      at org.jboss.system.ServiceMBeanSupport.jbossInternalCreate(ServiceMBeanSupport.java:245)
      at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:228)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
      at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:943)
      at $Proxy0.create(Unknown Source)
      at org.jboss.system.ServiceController.create(ServiceController.java:341)
      at org.jboss.system.ServiceController.create(ServiceController.java:284)
      at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
      at $Proxy10.create(Unknown Source)
      at org.jboss.ejb3.EJB3Deployer.create(EJB3Deployer.java:208)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
      at $Proxy11.create(Unknown Source)
      at org.jboss.deployment.MainDeployer.create(MainDeployer.java:935)
      at org.jboss.deployment.MainDeployer.create(MainDeployer.java:925)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:789)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:753)
      at sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
      at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:118)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
      at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:127)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
      at $Proxy6.deploy(Unknown Source)
      at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:319)
      at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:507)
      at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:192)
      at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:203)
      at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:182)


      note that the mappedBy annotation is remarked, this is because when I
      ommit this annotation, and configure it as follows :

      @OneToOne(targetEntity=OFacturaCompra.class, fetch=EAGER )
      @JoinColumn(name="FactId", referencedColumnName="FactId" )
      public OFacturaCompra getFact()
      {
       return fact;
      }
      
      


      it deploys with no exceptions.

      I would like to know whether this behaviour is normal as far as the original configuration follows what the Hibernate Annotations and EJB3 Persistence Guides say about OneToOne; or there is something I am not doing well.

      Thanks in advance
      Alvaro E Martinez
      alvarommz@yahoo.com