[JBoss-user] [EJB 3.0] - OneToOne problem

2005-12-21 Thread alvarommz
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:

anonymous wrote : 
  | 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:

[JBoss-user] [EJB 3.0] - @OneToOne problem ...

2005-12-14 Thread michael.c.small
I have two entities that I'm trying to associate using one to one.  Below is 
the code snippet for each:

In Relationship.java (an Entity)

  | private TascForce tascForce;
  | 
  | @OneToOne(cascade=Cascade.ALL, fetch=FetchType.EAGER)
  | @JoinColumn(name="fk_tasc_tascforce")
  | public TascForce getTascForce()
  | {
  | return(this.tascForce);
  | }
  | 
  | public void setTascForce(TascForce tascForce)
  | {
  |  this.tascForce = tascForce;
  | }
  | 

In TascForce.java (an Entity):

  | private Relationship relationship;
  | 
  | @OneToOne(mappedBy="tascForce", fetch=FetchType.EAGER)
  | public Relationship getRelationship()
  | {
  |  return(this.relationship);
  | }
  | 
  | public void setRelationship(Relationship relationship)
  | {
  |  this.relationship = relationship;
  | }
  | 

Database schemas (in MySQL 5.0):

  | CREATE TABLE tasc_relationship (
  | internalKey BIGINT AUTO_INCREMENT NOT NULL PRIMARY KEY,
  | created DATETIME,
  | createdBy BINARY(15),
  | lastUpdated DATETIME,
  | lastUpdatedBy BINARY(15),
  | version BIGINT,
  | relationshipId BINARY(15),
  | loginId VARCHAR(150),
  | pin BINARY(6),
  | authenticationType ENUM('NATIVE', 'ACTIVE_DIRECTORY'),
  | lockedOut TINYINT(1),
  | fk_tasc_tascforce BIGINT
  | ) TYPE = Innodb;
  | 
  | CREATE TABLE tasc_tascforce (
  | internalKey BIGINT AUTO_INCREMENT NOT NULL PRIMARY KEY,
  | created DATETIME,
  | createdBy BINARY(15),
  | lastUpdated DATETIME,
  | lastUpdatedBy BINARY(15),
  | version BIGINT,
  | address1 VARCHAR(100),
  | address2 VARCHAR(100),
  | city VARCHAR(40),
  | state CHAR(2),
  | deliveryArea CHAR(5),
  | plusFour CHAR(4),
  | fk_tasc_contact BIGINT
  | ) TYPE = InnoDB;
  | 

I can successfully create a TascForce instance and search for a TascForce 
instance (i.e. no EJB errors and the database records look good), but when I 
attempt a EntityManager.merge on the TascForce object I get the following error:


  | 09:10:25,868 INFO  [LongType] could not bind value '[EMAIL 
PROTECTED]@1c02db5[internalKey=1,created=2005-12-14 08:47:02.0,[EMAIL 
PROTECTED],lastUpdated=Wed Dec 14 09:10:25 CST 2005,[EMAIL 
PROTECTED],version=1,[EMAIL 
PROTECTED],firstName=Michael,middleName=],[EMAIL 
PROTECTED],trunk=,number=,extension=],[EMAIL 
PROTECTED],trunk=,number=,extension=],[EMAIL 
PROTECTED],trunk=,number=,extension=],[EMAIL 
PROTECTED],trunk=,number=,extension=],[EMAIL 
PROTECTED]@tasconline.com]],address=]' to parameter: 1
  | 09:10:26,054 WARN  [JDBCExceptionReporter] SQL Error: 0, SQLState: S1009
  | 09:10:26,054 ERROR [JDBCExceptionReporter] Statement parameter 1 not set.
  | 09:10:26,056 ERROR [AjaxPhaseListener] AJAX request failed: null; 
CausedByException is:
  | could not load an entity: [EMAIL 
PROTECTED]@1c02db5[internalKey=1,created=2005-12-14 08:47:02.0,[EMAIL 
PROTECTED],lastUpdated=Wed Dec 14 09:10:25 CST 2005,[EMAIL 
PROTECTED],version=1,[EMAIL 
PROTECTED],firstName=Michael,middleName=],[EMAIL 
PROTECTED],trunk=,number=,extension=],[EMAIL 
PROTECTED],trunk=,number=,extension=],[EMAIL 
PROTECTED],trunk=,number=,extension=],[EMAIL 
PROTECTED],trunk=,number=,extension=],[EMAIL 
PROTECTED]@tasconline.com]],address=]]
  | javax.ejb.EJBException: null; CausedByException is:
  | could not load an entity: [EMAIL 
PROTECTED]@1c02db5[internalKey=1,created=2005-12-14 08:47:02.0,[EMAIL 
PROTECTED],lastUpdated=Wed Dec 14 09:10:25 CST 2005,[EMAIL 
PROTECTED],version=1,[EMAIL 
PROTECTED],firstName=Michael,middleName=],[EMAIL 
PROTECTED],trunk=,number=,extension=],[EMAIL 
PROTECTED],trunk=,number=,extension=],[EMAIL 
PROTECTED],trunk=,number=,extension=],[EMAIL 
PROTECTED],trunk=,number=,extension=],[EMAIL 
PROTECTED]@tasconline.com]],address=]]
  | at 
org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:46)
  | at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:70)
  | at 
org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:134)
  | at 
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
  | at 
org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:61)
  | at 
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
  | at 
org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:39)
  | at 
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
  | at 
org.jboss.aspects.security.RoleBasedAuthorizationInterceptor.invoke(RoleBasedAuthorizationInterceptor.java:151)
  | at 
org.jboss.ejb3.security.RoleBasedAuthorizationInterceptor.invoke(RoleBasedAuthorizationInterceptor.java:85)
  | at 
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
  | at 
org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:63)
  | at 
org.jboss.aop.joinpoint.MethodInvocation.invokeNext