Re: Class Hints
Jakob, Ok, I miss understood its purpose. I wanted and instance of PhoneNumber or PostalAddress, I guess it goes back to the bug Armin mentioned. I have modified my code to loop through the results and query for the appropriate table and set it in PartyContactMech. Thanks for the clarification. I see now in the example that it is referencing a field in the extended table. -chris worley hi chris, adding a path class makes only sense when you hava a path in your query. ie: crit.addEqualTo("contactMech.something", on other thing); crit.addPathClass("contactMech", CPhoneNumber.class); jakob Chris Worley schrieb: Jakob, -- with hints and extents defined for CContactMech Integer partyId = (Integer) getParameter("partyId"); Criteria crit = new Criteria(); crit.addEqualTo("partyId", partyId); crit.addPathClass("contactMech", CPhoneNumber.class); Criteria critAddress = new Criteria(); critAddress.addEqualTo("partyId", partyId); critAddress.addPathClass("contactMech", CPostalAddress.class); crit.addOrCriteria(critAddress); Query query = QueryFactory.newQuery(CPartyContactMech.class, crit); Collection partyContactMechs = getBroker().getCollectionByQuery(query); [org.apache.ojb.broker.core.QueryReferenceBroker] DEBUG: getCollectionByQuery (class org.apache.ojb.broker.util.collections.RemovalAwareCollection, class net.enterprise.common.model.party.CPartyContactMech, QueryByCriteria from class net.enterprise.common.model.party.CPartyContactMech where [partyId = 1, [partyId = 1]]) [org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement$TableAlias] DEBUG: TableAlias(): using hints ? false [org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl] DEBUG: SQL:SELECT A0.party_contact_mech_id,A0.party_id,A0.contact_mech_id,A0.from_date,A0.thru_date,A0.contact_mech_purpose_id FROM party_contact_mech A0 WHERE A0.party_id = ? OR (A0.party_id = ?) [org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement$TableAlias] DEBUG: TableAlias(): using hints ? false [org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl] DEBUG: SQL:SELECT A0.contact_mech_id,A0.contact_mech_type_id FROM contact_mech A0 WHERE A0.contact_mech_id = ? [org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement$TableAlias] DEBUG: TableAlias(): using hints ? false [org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement$TableAlias] DEBUG: TableAlias(): using hints ? false [org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl] DEBUG: SQL:SELECT A0.contact_mech_id,A0.country_code,A0.area_code,A0.contact_number FROM phone_number A0 INNER JOIN contact_mech A1 ON A0.contact_mech_id=A1.contact_mech_id WHERE A0.contact_mech_id = ? [org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement$TableAlias] DEBUG: TableAlias(): using hints ? false [org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement$TableAlias] DEBUG: TableAlias(): using hints ? false [org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl] DEBUG: SQL:SELECT A0.contact_mech_id,A0.to_name,A0.attention,A0.address1,A0.address2,A0.city,A0.postal_code,A0.state_geo_id,A0.country_geo_id FROM postal_address A0 INNER JOIN contact_mech A1 ON A0.contact_mech_id=A1.contact_mech_id WHERE A0.contact_mech_id = ? [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Materialisation of object is finished, push 2objects to cache [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Push to cache: net.enterprise.common.model.party.CPartyContactMech{1} [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Push to cache: net.enterprise.common.model.contact.CContactMech{2} -- without hints and extents defined for CContactMech Integer partyId = (Integer) getParameter("partyId"); Criteria crit = new Criteria(); crit.addEqualTo("partyId", partyId); Query query = QueryFactory.newQuery(CPartyContactMech.class, crit); Collection partyContactMechs = getBroker().getCollectionByQuery(query); [org.apache.ojb.broker.core.QueryReferenceBroker] DEBUG: getCollectionByQuery (class org.apache.ojb.broker.util.collections.RemovalAwareCollection, class net.enterprise.common.model.party.CPartyContactMech, QueryByCriteria from class net.enterprise.common.model.party.CPartyContactMech where [partyId = 1]) [org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement$TableAlias] DEBUG: TableAlias(): using hints ? false [org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl] DEBUG: SQL:SELECT A0.party_contact_mech_id,A0.party_id,A0.contact_mech_id,A0.from_date,A0.thru_date,A0.contact_mech_purpose_id FROM party_contact_mech A0 WHERE A0.party_id = ? [org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement$TableAlias] DEBUG: TableAlias(): using hints ? false [org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl] DEBUG: SQL:SELECT A0.contact_mech_id,A0.contact_mech_type_id FROM contact_mech A0 WHERE A0.contact_mech_id =
Re: Class Hints
qlQueryStatement$TableAlias] DEBUG: TableAlias(): using hints ? false [org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl] DEBUG: SQL:SELECT A0.contact_mech_id,A0.to_name,A0.attention,A0.address1,A0.address2,A0.city,A0.postal_code,A0.state_geo_id,A0.country_geo_id FROM postal_address A0 INNER JOIN contact_mech A1 ON A0.contact_mech_id=A1.contact_mech_id WHERE A0.contact_mech_id = ? [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Materialisation of object is finished, push 2objects to cache [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Push to cache: net.enterprise.common.model.party.CPartyContactMech{1} [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Push to cache: net.enterprise.common.model.contact.CContactMech{2} -chris worley hi chris, please post the sql with and without the hints. jakob Chris Worley schrieb: Actually I don't think this problem is directly related to class hints. In a previous thread Armin mentioned to me that there was a but that will be fixed in the next released previouse email from Armin: > In the next version of OJB this will be fixed (or try the OJB_1_0_RELEASE branch from CVS) and > CParty party = (CParty) getBroker().getObjectByIdentity(oid); > will always return the correct object instance (CParty, CPartyGroup or Person) and you can directly cast to the real party type. -chris worley I am having a problem with class hints. They do not seem to work all the time with my configuration. If the PartyContactMech object is stored in the same instance of the server process that I retreive it in PartyContactMech.contactMech is populated with an instance of CPhoneNumber or CPostalAddress. If I try to reteive a records that were created in a previous instance of the process then PartyContactMech.contactMechs is populated with an instance of ContactMech. Integer partyId = (Integer) getParameter("partyId"); Criteria crit = new Criteria(); crit.addEqualTo("partyId", partyId); crit.addPathClass("contactMech", CPhoneNumber.class); Criteria critAddress = new Criteria(); critAddress.addEqualTo("partyId", partyId); critAddress.addPathClass("contactMech", CPostalAddress.class); crit.addOrCriteria(critAddress); Query query = QueryFactory.newQuery(CPartyContactMech.class, crit); Collection partyContactMechs = getBroker().getCollectionByQuery(query); setParameter("partyContactMechs", partyContactMechs); class-ref="net.enterprise.common.model.contact.CPhoneNumber"/> class-ref="net.enterprise.common.model.contact.CPostalAddress"/> - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Class Hints
Actually I don't think this problem is directly related to class hints. In a previous thread Armin mentioned to me that there was a but that will be fixed in the next released previouse email from Armin: > In the next version of OJB this will be fixed (or try the OJB_1_0_RELEASE branch from CVS) and > CParty party = (CParty) getBroker().getObjectByIdentity(oid); > will always return the correct object instance (CParty, CPartyGroup or Person) and you can directly cast to the real party type. -chris worley I am having a problem with class hints. They do not seem to work all the time with my configuration. If the PartyContactMech object is stored in the same instance of the server process that I retreive it in PartyContactMech.contactMech is populated with an instance of CPhoneNumber or CPostalAddress. If I try to reteive a records that were created in a previous instance of the process then PartyContactMech.contactMechs is populated with an instance of ContactMech. Integer partyId = (Integer) getParameter("partyId"); Criteria crit = new Criteria(); crit.addEqualTo("partyId", partyId); crit.addPathClass("contactMech", CPhoneNumber.class); Criteria critAddress = new Criteria(); critAddress.addEqualTo("partyId", partyId); critAddress.addPathClass("contactMech", CPostalAddress.class); crit.addOrCriteria(critAddress); Query query = QueryFactory.newQuery(CPartyContactMech.class, crit); Collection partyContactMechs = getBroker().getCollectionByQuery(query); setParameter("partyContactMechs", partyContactMechs); class-ref="net.enterprise.common.model.contact.CPhoneNumber"/> class-ref="net.enterprise.common.model.contact.CPostalAddress"/> - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Class Hints
I am having a problem with class hints. They do not seem to work all the time with my configuration. If the PartyContactMech object is stored in the same instance of the server process that I retreive it in PartyContactMech.contactMech is populated with an instance of CPhoneNumber or CPostalAddress. If I try to reteive a records that were created in a previous instance of the process then PartyContactMech.contactMechs is populated with an instance of ContactMech. Integer partyId = (Integer) getParameter("partyId"); Criteria crit = new Criteria(); crit.addEqualTo("partyId", partyId); crit.addPathClass("contactMech", CPhoneNumber.class); Criteria critAddress = new Criteria(); critAddress.addEqualTo("partyId", partyId); critAddress.addPathClass("contactMech", CPostalAddress.class); crit.addOrCriteria(critAddress); Query query = QueryFactory.newQuery(CPartyContactMech.class, crit); Collection partyContactMechs = getBroker().getCollectionByQuery(query); setParameter("partyContactMechs", partyContactMechs); class-ref="net.enterprise.common.model.contact.CPhoneNumber"/> class-ref="net.enterprise.common.model.contact.CPostalAddress"/> name="contactMechId" column="contact_mech_id" jdbc-type="integer" primarykey="true" autoincrement="true" /> name="contactMechTypeId" column="contact_mech_type_id" jdbc-type="varchar" /> - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: IllegalAccess When Setting Field
Armin, I removed the dynamic proxy from the class descriptors and every thing works fine. I have not studied them enough to undertand how to handle them. -chris worley Hi, ok, now we have a more detailed error message: [PersistentField] ERROR: while set field: [try to set 'object value' in 'target object' target obj class: net.enterprise.common.model.party.CPartyContactMech target field name: contactMech target field type: class net.enterprise.common.model.contact.CContactMech target field declared in: net.enterprise.common.model.party.CPartyContactMech object value class: $Proxy0 object value: [EMAIL PROTECTED] ] Seems that OJB try to set the field in a correct way. You declare CContactMech as dynamic proxy and OJB try to set such an instance in CPartyContactMech. Think the field you declare in CPartyContactMech have to be an Interface if you want to use a normal dynamic proxy in this case Why did you declare CContactMech class objects as proxy? Wouldn't it be better to use a proxy-reference for the 1:1 relation between CPartyContactMech and CContactMech? regards, Armin Chris Worley wrote: Armin, Here is the complete output at the time the service is invoked. For this I have set all proxies back to dynamic in the class descriptors. If I comment out the reference to the contactMech the party reference gets populated just fine. I am not sure what the deail is with the ContactMech. [org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl] DEBUG: createPool was called [org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl] DEBUG: makeObject called [org.apache.ojb.broker.accesslayer.StatementManager] DEBUG: closeResources was called [org.apache.ojb.broker.core.QueryReferenceBroker] DEBUG: getCollectionByQuery (class org.apache.ojb.broker.util.collections.RemovalAwareCollection, class net.enterprise.common.model.party.CPartyRole, QueryByCriteria from class net.enterprise.common.model.party.CPartyRole where [partyId = 181]) [org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement$TableAlias] DEBUG: TableAlias(): using hints ? false [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Materialisation of object is finished, push 1objects to cache [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Push to cache: net.enterprise.common.model.party.CParty{181} [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Clear materialization cache [org.apache.ojb.broker.accesslayer.StatementManager] DEBUG: closeResources was called [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Materialisation of object is finished, push 1objects to cache [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Push to cache: net.enterprise.common.model.party.CPartyGroup{181} [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Clear materialization cache [org.apache.ojb.broker.core.QueryReferenceBroker] DEBUG: getCollectionByQuery (class org.apache.ojb.broker.util.collections.RemovalAwareCollection, class net.enterprise.common.model.party.CPartyContactMech, QueryByCriteria from class net.enterprise.common.model.party.CPartyContactMech where [partyId = 181, [partyId = 181]]) [org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement$TableAlias] DEBUG: TableAlias(): using hints ? false [org.apache.ojb.broker.core.PersistenceBrokerFactoryBaseImpl] INFO: Create new PB instance for PBKey org.apache.ojb.broker.PBKey: jcdAlias=enterprise, user=enterprise, password=*, already created persistence broker instances: 1 [org.apache.ojb.broker.cache.ObjectCacheFactory] INFO: Start creating new ObjectCache instance [org.apache.ojb.broker.cache.ObjectCacheFactory] INFO: Instantiate new org.apache.ojb.broker.cache.CacheDistributor for PB instance [EMAIL PROTECTED] [org.apache.ojb.broker.cache.ObjectCacheFactory] INFO: New ObjectCache instance was created [org.apache.ojb.broker.util.sequence.SequenceManagerFactory] DEBUG: create new sequence manager for broker [EMAIL PROTECTED] [org.apache.ojb.broker.util.sequence.SequenceManagerFactory] DEBUG: Jdbc-Connection-Descriptor 'enterprise' use sequence manager: class org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl [org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl] DEBUG: makeObject called [org.apache.ojb.broker.accesslayer.StatementManager] DEBUG: closeResources was called [org.apache.ojb.broker.accesslayer.StatementManager] DEBUG: closeResources was called [PersistentField] ERROR: while set field: [try to set 'object value' in 'target object' target obj class: net.enterprise.common.model.party.CPartyContactMech target field name: contactMech target field type: class net.enterprise.common.model.contact.CContactMech target field declared in: net.enterprise.common.model.party.CPartyContactMech object value class: $Proxy0 object value: [EMAIL PROTECTED] ] [org.apache.ojb.broker.cache.Ma
Re: IllegalAccess When Setting Field
Armin, My ojb version is 1.0.3. -chris worley Armin, Here is the complete output at the time the service is invoked. For this I have set all proxies back to dynamic in the class descriptors. If I comment out the reference to the contactMech the party reference gets populated just fine. I am not sure what the deail is with the ContactMech. [org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl] DEBUG: createPool was called [org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl] DEBUG: makeObject called [org.apache.ojb.broker.accesslayer.StatementManager] DEBUG: closeResources was called [org.apache.ojb.broker.core.QueryReferenceBroker] DEBUG: getCollectionByQuery (class org.apache.ojb.broker.util.collections.RemovalAwareCollection, class net.enterprise.common.model.party.CPartyRole, QueryByCriteria from class net.enterprise.common.model.party.CPartyRole where [partyId = 181]) [org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement$TableAlias] DEBUG: TableAlias(): using hints ? false [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Materialisation of object is finished, push 1objects to cache [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Push to cache: net.enterprise.common.model.party.CParty{181} [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Clear materialization cache [org.apache.ojb.broker.accesslayer.StatementManager] DEBUG: closeResources was called [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Materialisation of object is finished, push 1objects to cache [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Push to cache: net.enterprise.common.model.party.CPartyGroup{181} [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Clear materialization cache [org.apache.ojb.broker.core.QueryReferenceBroker] DEBUG: getCollectionByQuery (class org.apache.ojb.broker.util.collections.RemovalAwareCollection, class net.enterprise.common.model.party.CPartyContactMech, QueryByCriteria from class net.enterprise.common.model.party.CPartyContactMech where [partyId = 181, [partyId = 181]]) [org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement$TableAlias] DEBUG: TableAlias(): using hints ? false [org.apache.ojb.broker.core.PersistenceBrokerFactoryBaseImpl] INFO: Create new PB instance for PBKey org.apache.ojb.broker.PBKey: jcdAlias=enterprise, user=enterprise, password=*, already created persistence broker instances: 1 [org.apache.ojb.broker.cache.ObjectCacheFactory] INFO: Start creating new ObjectCache instance [org.apache.ojb.broker.cache.ObjectCacheFactory] INFO: Instantiate new org.apache.ojb.broker.cache.CacheDistributor for PB instance [EMAIL PROTECTED] [org.apache.ojb.broker.cache.ObjectCacheFactory] INFO: New ObjectCache instance was created [org.apache.ojb.broker.util.sequence.SequenceManagerFactory] DEBUG: create new sequence manager for broker [EMAIL PROTECTED] [org.apache.ojb.broker.util.sequence.SequenceManagerFactory] DEBUG: Jdbc-Connection-Descriptor 'enterprise' use sequence manager: class org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl [org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl] DEBUG: makeObject called [org.apache.ojb.broker.accesslayer.StatementManager] DEBUG: closeResources was called [org.apache.ojb.broker.accesslayer.StatementManager] DEBUG: closeResources was called [PersistentField] ERROR: while set field: [try to set 'object value' in 'target object' target obj class: net.enterprise.common.model.party.CPartyContactMech target field name: contactMech target field type: class net.enterprise.common.model.contact.CContactMech target field declared in: net.enterprise.common.model.party.CPartyContactMech object value class: $Proxy0 object value: [EMAIL PROTECTED] ] [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Clear materialization cache [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Clear materialization cache [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Clear materialization cache [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Clear materialization cache [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Clear materialization cache [org.apache.ojb.broker.cache.MaterializationCache] DEBUG: Clear materialization cache org.apache.ojb.broker.PersistenceBrokerException: Error invoking method afterLookup at org.apache.ojb.broker.core.proxy.IndirectionHandlerDefaultImpl.invoke(Unknown Source) at $Proxy0.afterLookup(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerAbstractImpl.performCallBack(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerAbstractImpl.fireBrokerEvent(Unknown Source) at org.apache.ojb.broker.accesslayer.RsIterator.next(Unknown Source) at org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(Unknown Source) at org.apache.ojb.broker.core.QueryReferenceBroke
Re: IllegalAccess When Setting Field
ByQuery(Unknown Source) at org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQuery(Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQuery(Unknown Source) at net.enterprise.server.service.contact.CFindPartyContactMechByPartyIdService.doExecute(CFindPartyContactMechByPartyIdService.java:43) at net.enterprise.common.service.CService.execute(CService.java:45) at net.enterprise.common.service.CServiceExecutor.execute(CServiceExecutor.java:66) at net.enterprise.common.service.CLocalDispatcher.execute(CLocalDispatcher.java:41) at net.enterprise.server.service.contact.CFindContactService.doExecute(CFindContactService.java:48) at net.enterprise.common.service.CService.execute(CService.java:45) at net.enterprise.common.service.CServiceExecutor.execute(CServiceExecutor.java:66) at net.enterprise.server.service.CServiceProcess.run(CServiceProcess.java:53) Caused by: org.apache.ojb.broker.PersistenceBrokerException: org.apache.ojb.broker.metadata.MetadataException: IllegalAccess error setting field:contactMech in object:net.enterprise.common.model.party.CPartyContactMech at org.apache.ojb.broker.core.proxy.IndirectionHandlerDefaultImpl.materializeSubject(Unknown Source) at org.apache.ojb.broker.core.proxy.IndirectionHandlerDefaultImpl.getRealSubject(Unknown Source) ... 19 more Caused by: org.apache.ojb.broker.metadata.MetadataException: IllegalAccess error setting field:contactMech in object:net.enterprise.common.model.party.CPartyContactMech at org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDirectAccessImplNew.setValueFor(Unknown Source) at org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDirectAccessImplNew.set(Unknown Source) at org.apache.ojb.broker.core.QueryReferenceBroker.retrieveReference(Unknown Source) at org.apache.ojb.broker.core.QueryReferenceBroker.retrieveReferences(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getDBObject(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.doGetObjectByIdentity(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByIdentity(Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByIdentity(Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByIdentity(Unknown Source) ... 21 more Caused by: java.lang.IllegalArgumentException at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:63) at java.lang.reflect.Field.set(Field.java:519) ... 30 more Hi Chris, which version of OJB do you use? Normally OJB will generate a more detailed error log when field setting fails. Caused by: org.apache.ojb.broker.metadata.MetadataException: IllegalAccess error setting field:contactMech in object:net.enterprise.common.model.party.CPartyContactMech Did you post the whole stack trace with complete error log? regards, Armin Chris Worley wrote: I have now removed proxy="dynamic" from all my class descriptors and I no longer get the exception. After doing some testing. I am finding that sometimes I get the exception, sometimes it works and sometimes the contactMech is populated with an instance of CPhoneNumber (which is what i want) and sometimes it just populates with CContactMech. CPhoneNumber extends CContactMech. I have modified the code on the server to use class hints. The only pattern I am finding is that I can retreive the PartyContactMech without an exception if the obejct was created during the life of the server process. If i start the server and retreive one that was not created during the life of the process then I get the exception. Sounds like it works fine when the objects are cached, but thats just an assumption. I also stopped using a the dynamic proxy for PartyContactMech. -chris worley I have a similar error when using. I am able to set fields with other objects when retreiving them from the db. This particular class is giving me some problems. PersistentFieldClass=org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldIntrospectorImplNew org.apache.ojb.broker.PersistenceBrokerException: Error invoking method afterLookup at org.apache.ojb.broker.core.proxy.IndirectionHandlerDefaultImpl.invoke(Unknown Source) at $Proxy0.afterLookup(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerAbstractImpl.performCallBack(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerAbstractImpl.fireBrokerEvent(Unknown Source) at org.apache.ojb.broker.accesslayer.RsIterator.next(Unknown Source) at org.apache.ojb.broker.core.QueryReferenceBroker.get
Re: IllegalAccess When Setting Field
I have now removed proxy="dynamic" from all my class descriptors and I no longer get the exception. After doing some testing. I am finding that sometimes I get the exception, sometimes it works and sometimes the contactMech is populated with an instance of CPhoneNumber (which is what i want) and sometimes it just populates with CContactMech. CPhoneNumber extends CContactMech. I have modified the code on the server to use class hints. The only pattern I am finding is that I can retreive the PartyContactMech without an exception if the obejct was created during the life of the server process. If i start the server and retreive one that was not created during the life of the process then I get the exception. Sounds like it works fine when the objects are cached, but thats just an assumption. I also stopped using a the dynamic proxy for PartyContactMech. -chris worley I have a similar error when using. I am able to set fields with other objects when retreiving them from the db. This particular class is giving me some problems. PersistentFieldClass=org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldIntrospectorImplNew org.apache.ojb.broker.PersistenceBrokerException: Error invoking method afterLookup at org.apache.ojb.broker.core.proxy.IndirectionHandlerDefaultImpl.invoke(Unknown Source) at $Proxy0.afterLookup(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerAbstractImpl.performCallBack(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerAbstractImpl.fireBrokerEvent(Unknown Source) at org.apache.ojb.broker.accesslayer.RsIterator.next(Unknown Source) at org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(Unknown Source) at org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(Unknown Source) at org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQuery(Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQuery(Unknown Source) at net.enterprise.server.service.contact.CFindPartyContactMechByPartyIdService.doExecute(CFindPartyContactMechByPartyIdService.java:31) at net.enterprise.common.service.CService.execute(CService.java:45) at net.enterprise.common.service.CServiceExecutor.execute(CServiceExecutor.java:66) at net.enterprise.common.service.CLocalDispatcher.execute(CLocalDispatcher.java:41) at net.enterprise.server.service.contact.CFindContactService.doExecute(CFindContactService.java:48) at net.enterprise.common.service.CService.execute(CService.java:45) at net.enterprise.common.service.CServiceExecutor.execute(CServiceExecutor.java:66) at net.enterprise.server.service.CServiceProcess.run(CServiceProcess.java:53) Caused by: org.apache.ojb.broker.PersistenceBrokerException: org.apache.ojb.broker.metadata.MetadataException: Error invoking method:setContactMech in object:net.enterprise.common.model.party.CPartyContactMech at org.apache.ojb.broker.core.proxy.IndirectionHandlerDefaultImpl.materializeSubject(Unknown Source) at org.apache.ojb.broker.core.proxy.IndirectionHandlerDefaultImpl.getRealSubject(Unknown Source) ... 19 more Caused by: org.apache.ojb.broker.metadata.MetadataException: Error invoking method:setContactMech in object:net.enterprise.common.model.party.CPartyContactMech at org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldIntrospectorImplNew.setValueFor(Unknown Source) at org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldIntrospectorImplNew.set(Unknown Source) at org.apache.ojb.broker.core.QueryReferenceBroker.retrieveReference(Unknown Source) at org.apache.ojb.broker.core.QueryReferenceBroker.retrieveReferences(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getDBObject(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.doGetObjectByIdentity(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByIdentity(Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByIdentity(Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByIdentity(Unknown Source) ... 21 more Caused by: java.lang.IllegalArgumentException: argument type mismatch 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:324) ... 30 more I get and IllegalAccess exception when ojb tries to populate a reference to another object. I have no problems s
Re: IllegalAccess When Setting Field
After doing some testing. I am finding that sometimes I get the exception, sometimes it works and sometimes the contactMech is populated with an instance of CPhoneNumber (which is what i want) and sometimes it just populates with CContactMech. CPhoneNumber extends CContactMech. I have modified the code on the server to use class hints. The only pattern I am finding is that I can retreive the PartyContactMech without an exception if the obejct was created during the life of the server process. If i start the server and retreive one that was not created during the life of the process then I get the exception. Sounds like it works fine when the objects are cached, but thats just an assumption. I also stopped using a the dynamic proxy for PartyContactMech. -chris worley I have a similar error when using. I am able to set fields with other objects when retreiving them from the db. This particular class is giving me some problems. PersistentFieldClass=org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldIntrospectorImplNew org.apache.ojb.broker.PersistenceBrokerException: Error invoking method afterLookup at org.apache.ojb.broker.core.proxy.IndirectionHandlerDefaultImpl.invoke(Unknown Source) at $Proxy0.afterLookup(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerAbstractImpl.performCallBack(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerAbstractImpl.fireBrokerEvent(Unknown Source) at org.apache.ojb.broker.accesslayer.RsIterator.next(Unknown Source) at org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(Unknown Source) at org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(Unknown Source) at org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQuery(Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQuery(Unknown Source) at net.enterprise.server.service.contact.CFindPartyContactMechByPartyIdService.doExecute(CFindPartyContactMechByPartyIdService.java:31) at net.enterprise.common.service.CService.execute(CService.java:45) at net.enterprise.common.service.CServiceExecutor.execute(CServiceExecutor.java:66) at net.enterprise.common.service.CLocalDispatcher.execute(CLocalDispatcher.java:41) at net.enterprise.server.service.contact.CFindContactService.doExecute(CFindContactService.java:48) at net.enterprise.common.service.CService.execute(CService.java:45) at net.enterprise.common.service.CServiceExecutor.execute(CServiceExecutor.java:66) at net.enterprise.server.service.CServiceProcess.run(CServiceProcess.java:53) Caused by: org.apache.ojb.broker.PersistenceBrokerException: org.apache.ojb.broker.metadata.MetadataException: Error invoking method:setContactMech in object:net.enterprise.common.model.party.CPartyContactMech at org.apache.ojb.broker.core.proxy.IndirectionHandlerDefaultImpl.materializeSubject(Unknown Source) at org.apache.ojb.broker.core.proxy.IndirectionHandlerDefaultImpl.getRealSubject(Unknown Source) ... 19 more Caused by: org.apache.ojb.broker.metadata.MetadataException: Error invoking method:setContactMech in object:net.enterprise.common.model.party.CPartyContactMech at org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldIntrospectorImplNew.setValueFor(Unknown Source) at org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldIntrospectorImplNew.set(Unknown Source) at org.apache.ojb.broker.core.QueryReferenceBroker.retrieveReference(Unknown Source) at org.apache.ojb.broker.core.QueryReferenceBroker.retrieveReferences(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getDBObject(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.doGetObjectByIdentity(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByIdentity(Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByIdentity(Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByIdentity(Unknown Source) ... 21 more Caused by: java.lang.IllegalArgumentException: argument type mismatch 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:324) ... 30 more I get and IllegalAccess exception when ojb tries to populate a reference to another object. I have no problems storing the object. The exception is attached and below is my code and mapping. - Code Integer partyId
Re: IllegalAccess When Setting Field
I have a similar error when using. I am able to set fields with other objects when retreiving them from the db. This particular class is giving me some problems. PersistentFieldClass=org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldIntrospectorImplNew org.apache.ojb.broker.PersistenceBrokerException: Error invoking method afterLookup at org.apache.ojb.broker.core.proxy.IndirectionHandlerDefaultImpl.invoke(Unknown Source) at $Proxy0.afterLookup(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerAbstractImpl.performCallBack(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerAbstractImpl.fireBrokerEvent(Unknown Source) at org.apache.ojb.broker.accesslayer.RsIterator.next(Unknown Source) at org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(Unknown Source) at org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(Unknown Source) at org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQuery(Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQuery(Unknown Source) at net.enterprise.server.service.contact.CFindPartyContactMechByPartyIdService.doExecute(CFindPartyContactMechByPartyIdService.java:31) at net.enterprise.common.service.CService.execute(CService.java:45) at net.enterprise.common.service.CServiceExecutor.execute(CServiceExecutor.java:66) at net.enterprise.common.service.CLocalDispatcher.execute(CLocalDispatcher.java:41) at net.enterprise.server.service.contact.CFindContactService.doExecute(CFindContactService.java:48) at net.enterprise.common.service.CService.execute(CService.java:45) at net.enterprise.common.service.CServiceExecutor.execute(CServiceExecutor.java:66) at net.enterprise.server.service.CServiceProcess.run(CServiceProcess.java:53) Caused by: org.apache.ojb.broker.PersistenceBrokerException: org.apache.ojb.broker.metadata.MetadataException: Error invoking method:setContactMech in object:net.enterprise.common.model.party.CPartyContactMech at org.apache.ojb.broker.core.proxy.IndirectionHandlerDefaultImpl.materializeSubject(Unknown Source) at org.apache.ojb.broker.core.proxy.IndirectionHandlerDefaultImpl.getRealSubject(Unknown Source) ... 19 more Caused by: org.apache.ojb.broker.metadata.MetadataException: Error invoking method:setContactMech in object:net.enterprise.common.model.party.CPartyContactMech at org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldIntrospectorImplNew.setValueFor(Unknown Source) at org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldIntrospectorImplNew.set(Unknown Source) at org.apache.ojb.broker.core.QueryReferenceBroker.retrieveReference(Unknown Source) at org.apache.ojb.broker.core.QueryReferenceBroker.retrieveReferences(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getDBObject(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.doGetObjectByIdentity(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByIdentity(Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByIdentity(Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByIdentity(Unknown Source) ... 21 more Caused by: java.lang.IllegalArgumentException: argument type mismatch 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:324) ... 30 more I get and IllegalAccess exception when ojb tries to populate a reference to another object. I have no problems storing the object. The exception is attached and below is my code and mapping. - Code Integer partyId = (Integer) getParameter("partyId"); Criteria crit = new Criteria(); crit.addEqualTo("partyId", partyId); Query query = QueryFactory.newQuery(CPartyContactMech.class, crit); setParameter("partyContactMechs", getBroker().getCollectionByQuery(query)); Exception - Caused by: org.apache.ojb.broker.PersistenceBrokerException: org.apache.ojb.broker.metadata.MetadataException: IllegalAccess error setting field:contactMech in object:net.enterprise.common.model.party.CPartyContactMech Mapping --
IllegalAccess When Setting Field
I get and IllegalAccess exception when ojb tries to populate a reference to another object. I have no problems storing the object. The exception is attached and below is my code and mapping. - Code Integer partyId = (Integer) getParameter("partyId"); Criteria crit = new Criteria(); crit.addEqualTo("partyId", partyId); Query query = QueryFactory.newQuery(CPartyContactMech.class, crit); setParameter("partyContactMechs", getBroker().getCollectionByQuery(query)); Exception - Caused by: org.apache.ojb.broker.PersistenceBrokerException: org.apache.ojb.broker.metadata.MetadataException: IllegalAccess error setting field:contactMech in object:net.enterprise.common.model.party.CPartyContactMech Mapping -- name="contactMechId" column="contact_mech_id" jdbc-type="integer" primarykey="true" autoincrement="true" /> name="contactMechTypeId" column="contact_mech_type_id" jdbc-type="varchar" /> name="partyContactMechId" column="party_contact_mech_id" jdbc-type="integer" primarykey="true" autoincrement="true" /> name="partyId" column="party_id" jdbc-type="integer" /> name="contactMechId" column="contact_mech_id" jdbc-type="integer" /> name="fromDate" column="from_date" jdbc-type="timestamp" /> name="thruDate" column="thru_date" jdbc-type="timestamp" /> name="contactMechPurposeId" column="contact_mech_purpose_id" jdbc-type="integer" /> name="contactMech" class-ref="net.enterprise.common.model.contact.CContactMech" auto-retreive="true" auto-update="true" > name="party" class-ref="net.enterprise.common.model.party.CParty" auto-retreive="true" auto-update="true" > thanks -chris worley org.apache.ojb.broker.PersistenceBrokerException: Error invoking method afterLookup at org.apache.ojb.broker.core.proxy.IndirectionHandlerDefaultImpl.invoke(Unknown Source) at $Proxy0.afterLookup(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerAbstractImpl.performCallBack(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerAbstractImpl.fireBrokerEvent(Unknown Source) at org.apache.ojb.broker.accesslayer.RsIterator.next(Unknown Source) at org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(Unknown Source) at org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(Unknown Source) at org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQuery(Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQuery(Unknown Source) at net.enterprise.server.service.contact.CFindPartyContactMechByPartyIdService.doExecute(CFindPartyContactMechByPartyIdService.java:31) at net.enterprise.common.service.CService.execute(CService.java:45) at net.enterprise.common.service.CServiceExecutor.execute(CServiceExecutor.java:66) at net.enterprise.common.service.CLocalDispatcher.execute(CLocalDispatcher.java:41) at net.enterprise.server.service.contact.CFindContactService.doExecute(CFindContactService.java:48) at net.enterprise.common.service.CService.execute(CService.java:45) at net.enterprise.common.service.CServiceExecutor.execute(CServiceExecutor.java:66) at net.enterprise.server.service.CServiceProcess.run(CServiceProcess.java:53) Caused by: org.apache.ojb.broker.PersistenceBrokerException: org.apache.ojb.broker.metadata.MetadataException: IllegalAccess error setting field:contactMech in object:net.enterprise.common.model.party.CPartyContactMech at org.apache.ojb.broker.core.proxy.IndirectionHandlerDefaultImpl.materializeSubject(Unknown Source) at org.apache.ojb.broker.core.proxy.IndirectionHandlerDefaultImpl.getRealSubject(Unknown
Re: Forgein Key Not Set
geez... sometimes when you stare at xml to long the its hard to find the simplest mistakes. I did not have the foreignkey tag in my reference descriptor. problem solved -chris worley I have a problem where the forgein key ids are not set in the object or db after the forgein object has been created. TABLE_A -A_ID TABLE_B -B_ID -A_ID In the mappings tableB has a reference descriptor for tableA TableA tableA = new TableA(); TableB tableB = new TableB(); tableB.setA(tableA); At this point the objects are serialized, sent and recreated on the server. getBroker().store(tableA); getBroker().store(tableB); When I look in the db table_b has the value of 0 for a_id. When getBroker().store(tableA) is executed I can see the a_id set in tableB.tableA.a_id but, I do not see the change in tableB.a_id. When table b is stored the value for a_id remains unset with the value of 0 even though tableB.tableA.a_id has the value set to 1 or whatever it was assigned. -chris worley - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Forgein Key Not Set
I have a problem where the forgein key ids are not set in the object or db after the forgein object has been created. TABLE_A -A_ID TABLE_B -B_ID -A_ID In the mappings tableB has a reference descriptor for tableA TableA tableA = new TableA(); TableB tableB = new TableB(); tableB.setA(tableA); At this point the objects are serialized, sent and recreated on the server. getBroker().store(tableA); getBroker().store(tableB); When I look in the db table_b has the value of 0 for a_id. When getBroker().store(tableA) is executed I can see the a_id set in tableB.tableA.a_id but, I do not see the change in tableB.a_id. When table b is stored the value for a_id remains unset with the value of 0 even though tableB.tableA.a_id has the value set to 1 or whatever it was assigned. -chris worley - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: ClassCastException with getObjectByIdentity()
Armin, Hi Chris, Chris Worley wrote: In the following code I get a ClassCastException when querying for the PartyGroup or Person. PartyGroup and Person both extend Party. Party.partyTypeId will determine if the party is a person or party group. If the party is one of the two then I want to get the party group or person object and return it. However, when the code queries a second time for the person or party group a ClassCastException occurs. getObjectByIdeneity(...) is retruning an instance of CParty, even though when the Identity was build I passed CPartyGroup.class as the param no CParty.class. If I modify the code not to query for CParty first and just query for CPartyGroup I will get an instance of CPartyGroup. But, for some reason by building the CParty identity first the second attempt for CPartyGroup still returns an instance of CParty. and I have no idea why. Can anyone shed some light on what is going on and why I continue to get an instance of CParty and not CPartyGroup or CPerson. Which kind of inheritance do you use? In OJB <=1.0.3 there is a bug in retrieve objects using "Mapping Classes on Multiple Joined Tables" (see release notes, it's fixed in CVS OJB_1_0_RELEASE branch). > CParty party = (CParty) getBroker().getObjectByIdentity(oid); This call should return the correct object instance, no need to query with the correct partyIdType again. Could you post the metadata mapping for Party, Person, PartyGroup? Here is the mapping for the tree class. I solved my problem by removing the tags from the party descriptor. You did mention that I could do this in one query I an interested in knowing how. name="partyId" column="party_id" jdbc-type="integer" primarykey="true" autoincrement="true" /> name="partyTypeId" column="party_type_id" jdbc-type="varchar" /> name="partyId" column="party_id" jdbc-type="integer" primarykey="true" autoincrement="true" /> name="groupName" column="group_name" jdbc-type="varchar" /> class-ref="net.enterprise.common.model.party.CParty" auto-retrieve="true" auto-update="true" > name="partyId" column="party_id" jdbc-type="integer" primarykey="true" /> name="firstName" column="first_name" jdbc-type="varchar" /> name="middleName" column="middle_name" jdbc-type="varchar" /> name="lastName" column="last_name" jdbc-type="varchar" /> class-ref="net.enterprise.common.model.party.CParty" auto-retrieve="true" auto-update="true" auto-delete="true" > regards, Armin // Find the party Identity oid = getBroker().serviceIdentity().buildIdentity(CParty.class, partyId); CParty party = (CParty) getBroker().getObjectByIdentity(oid); if (CParty.TYPE_PARTY_GROUP.equals(party.getPartyTypeId())) { // Get the Party Group Identity partyGroupId = getBroker().serviceIdentity().buildIdentity(CPartyGroup.class, partyId); // ClastCastException here CPartyGroup partyGroup = (CPartyGroup) getBroker().getObjectByIdentity(partyGroupId); setParameter("party", partyGroup); } else if (CParty.TYPE_PERSON.equals(party.getPartyTypeId())) { // Get the person Identity personId = getBroker().serviceIdentity().buildIdentity(CPerson.class, partyId); // ClastCastException here CPerson person = (CPerson) getBroker().getObjectByIdentity(personId); setParameter("party", person); } else { setParameter("party", party); } -chris worley - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: ClassCastException with getObjectByIdentity()
I have found my problem. I was using the tag for in the descriptor for party referencing PartyGroup and Person. After removing the extent the correct instance is returned. -chris worley In the following code I get a ClassCastException when querying for the PartyGroup or Person. PartyGroup and Person both extend Party. Party.partyTypeId will determine if the party is a person or party group. If the party is one of the two then I want to get the party group or person object and return it. However, when the code queries a second time for the person or party group a ClassCastException occurs. getObjectByIdeneity(...) is retruning an instance of CParty, even though when the Identity was build I passed CPartyGroup.class as the param no CParty.class. If I modify the code not to query for CParty first and just query for CPartyGroup I will get an instance of CPartyGroup. But, for some reason by building the CParty identity first the second attempt for CPartyGroup still returns an instance of CParty. and I have no idea why. Can anyone shed some light on what is going on and why I continue to get an instance of CParty and not CPartyGroup or CPerson. // Find the party Identity oid = getBroker().serviceIdentity().buildIdentity(CParty.class, partyId); CParty party = (CParty) getBroker().getObjectByIdentity(oid); if (CParty.TYPE_PARTY_GROUP.equals(party.getPartyTypeId())) { // Get the Party Group Identity partyGroupId = getBroker().serviceIdentity().buildIdentity(CPartyGroup.class, partyId); // ClastCastException here CPartyGroup partyGroup = (CPartyGroup) getBroker().getObjectByIdentity(partyGroupId); setParameter("party", partyGroup); } else if (CParty.TYPE_PERSON.equals(party.getPartyTypeId())) { // Get the person Identity personId = getBroker().serviceIdentity().buildIdentity(CPerson.class, partyId); // ClastCastException here CPerson person = (CPerson) getBroker().getObjectByIdentity(personId); setParameter("party", person); } else { setParameter("party", party); } -chris worley - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
ClassCastException with getObjectByIdentity()
In the following code I get a ClassCastException when querying for the PartyGroup or Person. PartyGroup and Person both extend Party. Party.partyTypeId will determine if the party is a person or party group. If the party is one of the two then I want to get the party group or person object and return it. However, when the code queries a second time for the person or party group a ClassCastException occurs. getObjectByIdeneity(...) is retruning an instance of CParty, even though when the Identity was build I passed CPartyGroup.class as the param no CParty.class. If I modify the code not to query for CParty first and just query for CPartyGroup I will get an instance of CPartyGroup. But, for some reason by building the CParty identity first the second attempt for CPartyGroup still returns an instance of CParty. and I have no idea why. Can anyone shed some light on what is going on and why I continue to get an instance of CParty and not CPartyGroup or CPerson. // Find the party Identity oid = getBroker().serviceIdentity().buildIdentity(CParty.class, partyId); CParty party = (CParty) getBroker().getObjectByIdentity(oid); if (CParty.TYPE_PARTY_GROUP.equals(party.getPartyTypeId())) { // Get the Party Group Identity partyGroupId = getBroker().serviceIdentity().buildIdentity(CPartyGroup.class, partyId); // ClastCastException here CPartyGroup partyGroup = (CPartyGroup) getBroker().getObjectByIdentity(partyGroupId); setParameter("party", partyGroup); } else if (CParty.TYPE_PERSON.equals(party.getPartyTypeId())) { // Get the person Identity personId = getBroker().serviceIdentity().buildIdentity(CPerson.class, partyId); // ClastCastException here CPerson person = (CPerson) getBroker().getObjectByIdentity(personId); setParameter("party", person); } else { setParameter("party", party); } -chris worley - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]