Strange problem with one-to-many relationship
397504Dec 16 2004 — edited Dec 17 2004Hello everyone,
we have observed a strange behaviour of TopLink in one case in our project. A one-to-many relationship doesn't work as expected. We use BMP EJBs with WebSphere AS 5.1 and TopLink 9.0.4.3. We have two entity beans - StatusRoot and StatusGraph - with a one-to-many relationship from StatusRoot to StatusGraph. The relationship is uni-directional. Every time we try to access the associated StatusGraph from a StatusRoot entity, we get the following exception:
Exception [TOPLINK-7009] (OracleAS TopLink - 10g (9.0.4.3) (Build 040412)): oracle.toplink.exceptions.ValidationException
Exception-Beschreibung: Fehlender Deskriptor für [class ourcompany._StatusGraph_Stub]. Prüfen Sie, ob der Deskriptor richtig mit der Session registriert wurde..
at oracle.toplink.exceptions.ValidationException.missingDescriptor(ValidationException.java:601)
at oracle.toplink.publicinterface.UnitOfWork.registerExistingObject(UnitOfWork.java:2885)
at oracle.toplink.mappings.ObjectReferenceMapping.buildCloneForPartObject(ObjectReferenceMapping.java:47)
at oracle.toplink.internal.indirection.NoIndirectionPolicy.cloneAttribute(NoIndirectionPolicy.java:43)
at oracle.toplink.mappings.ForeignReferenceMapping.buildClone(ForeignReferenceMapping.java:160)
at oracle.toplink.internal.descriptors.ObjectBuilder.populateAttributesForClone(ObjectBuilder.java(Compiled Code))
at oracle.toplink.publicinterface.UnitOfWork.cloneAndRegisterObject(UnitOfWork.java:648)
at oracle.toplink.publicinterface.UnitOfWork.cloneAndRegisterObject(UnitOfWork.java:618)
at oracle.toplink.publicinterface.UnitOfWork.getFromIdentityMap(UnitOfWork.java:1708)
at oracle.toplink.publicinterface.UnitOfWork.registerExistingObject(UnitOfWork.java:2899)
at oracle.toplink.queryframework.ReadObjectQuery.registerObjectInUnitOfWork(ReadObjectQuery.java:509)
at oracle.toplink.publicinterface.UnitOfWork.internalExecuteQuery(UnitOfWork.java:2222)
at oracle.toplink.publicinterface.Session.executeQuery(Session.java:1086)
at oracle.toplink.publicinterface.Session.executeQuery(Session.java:1038)
at oracle.toplink.ejb.EJBDataStore.findObject(EJBDataStore.java:279)
at oracle.toplink.ejb.EJBDataStore.findByPrimaryKey(EJBDataStore.java:254)
at oracle.toplink.ejb.bmp.BMPEntityBase.findByPrimaryKey(BMPEntityBase.java:210)
But when we try to access the StatusGraph object directly by its primary key using the same session and everything else unchanged, we don't get the exception. So the missing descriptor, TopLink is complaining about, is obviously there but not found when using the relationship. We get the exception for both - indirect and direct relationships. This is the only place in the whole project where a relationship does not work, so we have no idea what the problem is with this relationship.
We use the following mapping (no indirection in this case, but we also tried indirection):
OneToOneMapping statusGraphMapping = new OneToOneMapping();
statusGraphMapping.setAttributeName("statusGraph");
statusGraphMapping.setGetMethodName("getStatusGraph");
statusGraphMapping.setSetMethodName("setStatusGraph");
statusGraphMapping.setReferenceClass(StatusGraphBean.class);
statusGraphMapping.dontUseIndirection();
statusGraphMapping.addForeignKeyFieldName("ST_STATUSROOT.STG_ID", "ST_STATUSGRAPH.STG_ID");
descriptor.addMapping(statusGraphMapping);
The mapping was generated by the mapping workbench, so there is obviously no typo or anything else in there.
If somebody has an idea or experienced the same problem, please tell us.
Thanks in advance for any hint,
Thomas