Return-Path: Mailing-List: contact ojb-dev-help@db.apache.org; run by ezmlm Delivered-To: mailing list ojb-dev@db.apache.org Received: (qmail 56806 invoked from network); 3 Apr 2003 08:38:16 -0000 Received: from unknown (HELO silicomp.com.sg) (203.125.251.139) by daedalus.apache.org with SMTP; 3 Apr 2003 08:38:16 -0000 Received: from smtp.silicomp.com.sg [192.168.0.231] by silicomp.com.sg [203.125.251.139] with SMTP (MDaemon.v3.5.6.R); Thu, 03 Apr 2003 16:49:34 +0800 Message-ID: <001c01c2f9bc$4dab3930$2c00a8c0@Beethoven> From: "Janet Song" To: , "Jakob Braeuchi" , "OJB Developers List" References: <00dc01c2f521$5504d0a0$2c00a8c0@Beethoven> <3E84834C.4060009@gmx.ch> <016e01c2f757$6ef376a0$2c00a8c0@Beethoven> <3E887A7E.8090000@gmx.ch> <3E88B00A.1030807@gmx.ch> Subject: Re: Problems when using composite primary keys Date: Thu, 3 Apr 2003 16:37:39 +0800 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4522.1200 X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 X-MDRemoteIP: 192.168.0.231 X-Return-Path: spy@silicomp.com.sg X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Thx Jakob, I've changed the IndirectionHandler class in the release 2 as you recomended: public Object invoke(Object proxy, Method method, Object[] args) { Object subject = null; try { subject = getRealSubject(); // handle toString differently for non-materialized proxies // to avoid materialization due to logging. if (subject == null) { if (method.getName() == "toString") { return "unmaterialized proxy for " + getIdentity(); } else { return null; } } else { Method m = subject.getClass().getMethod(method.getName(), method.getParameterTypes()); return m.invoke(subject, args); } } catch (Exception e) { log.error("Method invoking failed for method *"+method.getName()+"* on object "+subject, e); throw new PersistenceBrokerException("Error invoking:"+method.getName(),e); } } The following are entries in my descriptors files: ... ... I still get this error: [DEFAULT] WARN: OJB broker could not materialize com.fedex.data.CorePieceCounterImpl{188119,JP} submit flag: null [DEFAULT] WARN: OJB broker could not materialize com.fedex.data.CorePieceCounterImpl{188119,JP} Type flag: null [org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl] INFO: Destroy object was called, try to close connection: oracle.jdbc.driver.OracleConnection@16c163f Any help on this is appreciated. Thx regards, Janet ----- Original Message ----- From: "Jakob Braeuchi" To: "OJB Developers List" Sent: Tuesday, April 01, 2003 05:15 Subject: Re: Problems when using composite primary keys > hi janet, > > sorry, i overlooked the message in your stacktrace. > the following sample using multiple keys works for me: > > class="brj.ojb.MultiPkParent" > table="multipkparent" > > > name="id1" > column="key1" > jdbc-type="INTEGER" > primarykey="true" > /> > name="id2" > column="key2" > jdbc-type="VARCHAR" > primarykey="true" > /> > name="field1" > column="field1" > jdbc-type="VARCHAR" > /> > name="field2" > column="field2" > jdbc-type="VARCHAR" > /> > name="children" > element-class-ref="brj.ojb.MultiPkChild" > auto-retrieve="true" > auto-update="true" > auto-delete="true" > > > > > > > > class="brj.ojb.MultiPkChild" > table="multipkchild" > proxy="dynamic" > > > name="c_id1" > column="parent_key1" > jdbc-type="INTEGER" > primarykey="true" > /> > name="c_id2" > column="parent_key2" > jdbc-type="VARCHAR" > primarykey="true" > /> > name="field1" > column="field1" > jdbc-type="VARCHAR" > primarykey="true" > /> > name="parent" > class-ref="brj.ojb.MultiPkParent" > > > > > > > > jakob > > Jakob Braeuchi wrote: > > > hi janet, > > > > don't you get an error message like "[DEFAULT] WARN: OJB broker could > > not materialize ...." in the log before the npe occurs ? > > do you have access to the source of ojb ? > > if yes, please try to replace the following method in IndirectionHandler: > > > > public Object invoke(Object proxy, Method method, Object[] args) > > { > > Object subject = null; > > try > > { > > subject = getRealSubject(); > > // handle toString differently for > > non-materialized proxies > > // to avoid materialization due to logging. > > if (subject == null) > > { > > if (method.getName() == "toString") > > { > > return "unmaterialized proxy for " + getIdentity(); > > } > > else > > { > > return null; > > } > > } > > else > > { > > Method m = > > subject.getClass().getMethod(method.getName(), > > method.getParameterTypes()); > > return m.invoke(subject, args); > > } > > } > > catch (Exception e) > > { > > log.error("Method invoking failed for method > > *"+method.getName()+"* on object "+subject, e); > > throw new PersistenceBrokerException("Error > > invoking:"+method.getName(),e); > > } > > } > > > > > > hth > > jakob > > > > Janet Song wrote: > > > >> Hi, > >> > >> Thanks. Got that problem solved. It works fine when i map a compound > >> primary > >> key from one table to another with a single primary key. However when > >> i map > >> compound primary keys to compound primary keys, i get a > >> NullPointerException > >> which results from > >> [org.apache.ojb.broker.accesslayer.IndirectionHandler] > >> ERROR: Met..... > >> > >> > >> e.g Table A: > >> >> class = "com.data.A" > >> proxy="dynamic" > >> table = "Shipment"> > >> >> name = "shipmentOid" > >> column = "SHIPMENT_OID" > >> jdbc-type ="INTEGER" > >> primarykey = "true" > >> /> > >> >> name = "countryCode" > >> column = "REF_COUNTRY_CD" > >> jdbc-type ="VARCHAR" > >> primarykey = "true" > >> /> > >> .... > >> > >> >> name="piece" > >> class-ref="com.data.B" > >> proxy="true"> > >> > >> > >> > >> > >> > >> Table B: > >> > >> >> class = "com.data.B" > >> proxy="dynamic" > >> table = "Piece"> > >> >> name = "shipmentOidPiece" > >> column = "SHIPMENT_OID" > >> jdbc-type ="INTEGER" > >> primarykey = "true" > >> /> > >> >> name = "typeFlg" > >> column = "TYPE_FLG" > >> jdbc-type ="VARCHAR" > >> primarykey = "true" > >> /> > >> > >> >> name="piece" > >> class-ref="com.data.A" > >> proxy="true"> > >> > >> > >> > >> > >> > >> > >> [DEFAULT] WARN: OJB broker could not materialize > >> com.fedex.data.CorePieceCounterImpl{188119,JP} > >> [org.apache.ojb.broker.accesslayer.IndirectionHandler] ERROR: Method > >> invoking failed for method *getSubmitFlag* on object null > >> null > >> java.lang.NullPointerException > >> at > >> org.apache.ojb.broker.accesslayer.IndirectionHandler.invoke(Unknown > >> Source) > >> at $Proxy1.getSubmitFlag(Unknown Source) > >> at TestClient.testEqualCriteriaOneToOne(TestClient.java:104) > >> at TestClient.runApp(TestClient.java:78) > >> at TestClient.main(TestClient.java:71) > >> Exception in thread "main" java.lang.NullPointerException > >> at > >> org.apache.ojb.broker.accesslayer.IndirectionHandler.invoke(Unknown > >> Source) > >> at $Proxy1.getSubmitFlag(Unknown Source) > >> at TestClient.testEqualCriteriaOneToOne(TestClient.java:104) > >> at TestClient.runApp(TestClient.java:78) > >> at TestClient.main(TestClient.java:71) > >> rethrown as org.apache.ojb.broker.PersistenceBrokerException: Error > >> invoking:getSubmitFlag > >> at > >> org.apache.ojb.broker.accesslayer.IndirectionHandler.invoke(Unknown > >> Source) > >> at $Proxy1.getSubmitFlag(Unknown Source) > >> at TestClient.testEqualCriteriaOneToOne(TestClient.java:104) > >> at TestClient.runApp(TestClient.java:78) > >> at TestClient.main(TestClient.java:71) > >> Caused by: java.lang.NullPointerException > >> ... 5 more > >> > >> > >> Any help on this is appreciated. Thanks > >> > >> > >> regards. > >> > >> Janet > >> > >> ----- Original Message ----- > >> From: "Jakob Braeuchi" > >> To: "OJB Developers List" > >> Sent: Saturday, March 29, 2003 01:15 > >> Subject: Re: ArrayIndexOutOfBoundsException when using composite primary > >> keys > >> > >> > >> > >> > >>> hi janet, > >>> > >>> imo this problem is coming from a reference-descriptor not matching > >>> the > >>> number of pk fields in the referenced object: > >>> > >>> >>> class="brj.ojb.Person" > >>> table="tabPerson" > >>> > > >>> >>> name="id" > >>> column="id" > >>> jdbc-type="INTEGER" > >>> primarykey="true" <<<< pk1 > >>> autoincrement="true" > >>> conversion="brj.ojb.TestFieldConversion" > >>> /> > >>> >>> name="vorname" > >>> column="vorname" > >>> jdbc-type="VARCHAR" > >>> /> > >>> >>> name="name" > >>> column="name" > >>> jdbc-type="VARCHAR" > >>> primarykey="true" <<<< pk2 > >>> /> > >>> ... > >>> >>> name="partner" > >>> class-ref="brj.ojb.Person" > >>> proxy="true" > >>> > > >>> <<<< one fk ('name') is > >>> missing > >>> > >>> > >>> hth > >>> jakob > >>> > >>> > >>> Janet Song wrote: > >>> > >>> > >>> > >>>> Hi, > >>>> > >>>> When i map compound or composite primary keys, i get an > >>>> ArrayOutOfBoundsException. Single primary key is fine. Appreciate > >>>> it if > >>>> someone could shed some light on this problem. Thanks! > >>>> > >>>> > >>>> [org.apache.ojb.broker.accesslayer.JdbcAccessImpl] ERROR: > >>>> PersistenceBrokerException during the execution of materializeObject: > >>>> > >>> > >> Could > >> > >> > >>>> not generate primary key values for given Identity > >>>> com.fedex.data.CorePieceCounterImpl{188119}, exception was > >>>> java.lang.ArrayIndexOutOfBoundsException: 1: 1 > >>>> Could not generate primary key values for given Identity > >>>> com.fedex.data.CorePieceCounterImpl{188119}, exception was > >>>> java.lang.ArrayIndexOutOfBoundsException: 1: 1 > >>>> java.lang.ArrayIndexOutOfBoundsException: 1 > >>>> at org.apache.ojb.broker.util.BrokerHelper.getKeyValues(Unknown > >>>> Source) > >>>> at org.apache.ojb.broker.util.BrokerHelper.getKeyValues(Unknown > >>>> Source) > >>>> at > >>>> org.apache.ojb.broker.accesslayer.StatementManager.getKeyValues(Unknown > >>>> > >>>> Source) > >>>> at > >>>> org.apache.ojb.broker.accesslayer.StatementManager.bindSelect(Unknown > >>>> Source) > >>>> at > >>>> > >>> > >>> org.apache.ojb.broker.accesslayer.JdbcAccessImpl.materializeObject(Unknown > >>> > >>> > >>>> Source) > >>>> at > >>>> org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getDBObject(Unknown > >>>> Source) > >>>> at > >>>> > >>> > >>> org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getObjectByIdentity(Un > >>> > >> > >> k > >> > >> > >>>> nown Source) > >>>> at > >>>> > >>> > >>> org.apache.ojb.broker.singlevm.DelegatingPersistenceBroker.getObjectByIdent > >>> > >> > >> i > >> > >> > >>>> ty(Unknown Source) > >>>> at > >>>> > >>> > >>> org.apache.ojb.broker.accesslayer.IndirectionHandler.materializeSubject(Unk > >>> > >> > >> n > >> > >> > >>>> own Source) > >>>> at > >>>> > >>> > >>> org.apache.ojb.broker.accesslayer.IndirectionHandler.getRealSubject(Unknown > >>> > >>> > >>>> Source) > >>>> at > >>>> org.apache.ojb.broker.accesslayer.IndirectionHandler.invoke(Unknown > >>>> > >>> > >> Source) > >> > >> > >>>> at $Proxy1.getSubmitFlag(Unknown Source) > >>>> at TestClient.testEqualCriteriaOneToOne(TestClient.java:104) > >>>> > >>>> > >>>> regards, > >>>> > >>>> Janet > >>>> > >>>> > >>>> > >>>> --------------------------------------------------------------------- > >>>> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org > >>>> For additional commands, e-mail: ojb-dev-help@db.apache.org > >>>> > >>>> > >>>> > >>>> > >>>> > >>> > >>> --------------------------------------------------------------------- > >>> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org > >>> For additional commands, e-mail: ojb-dev-help@db.apache.org > >>> > >>> > >>> > >> > >> > >> > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org > >> For additional commands, e-mail: ojb-dev-help@db.apache.org > >> > >> > >> > >> > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org > > For additional commands, e-mail: ojb-dev-help@db.apache.org > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org > For additional commands, e-mail: ojb-dev-help@db.apache.org > > >