Hi Manuel, your code seams to be correct. The 2 debug messages "Loading class" appear as there are 2 similar debug statments in castor at SQLEngine line 1201 and line 1220 while the statement is only executed once at line 1224. You can check that yourself at:
http://cvs.castor.codehaus.org/viewrep/castor/castor/src/main/org/exolab/castor/jdo/engine/SQLEngine.java?r=1.42 Regards Ralf Castor JDO, committer Manuel Castrillon schrieb: > Hello > > The load method that takes the instance of the Object seems to be what I > wanted, however it still creates a new instance of my class. Here is my > method...Is this correct? > > public Object doLoad(Database db, Object pk, Object genObj) > throws Exception > { > try { > genObj=db.load(genObj.getClass(),pk,genObj); > } > catch (PersistenceException pe) { > log4jCat.error("DB load failed.", pe); > db.rollback(); > } > return genObj; > } > > Here is my result, notice how the repeated "Loading class" appears!!! > > > > INFO [AWT-EventQueue-0] (_Example.java:314_) - Begin UPDATE > > INFO [AWT-EventQueue-0] (_MapCable.java:39_) - new instance! > > INFO [AWT-EventQueue-0] (_Example.java:328_) - getCable called > > INFO [AWT-EventQueue-0] (_MapCable.java:39_) - new instance! > > DEBUG [AWT-EventQueue-0] (_SQLEngine.java:1201_) - Loading class: > com.mapping.MapCable using SQL: > [EMAIL PROTECTED] > > DEBUG [AWT-EventQueue-0] (_SQLEngine.java:1220_) - Loading class: > com.mapping.MapCable using SQL: > [EMAIL PROTECTED] > > inside Test_table:jdoSetTimeStamp():1138280152494 > > DEBUG [AWT-EventQueue-0] (_SQLEngine.java:1201_) - Loading class: > com.mapping.MapCableMaterial using SQL: > [EMAIL PROTECTED] > > DEBUG [AWT-EventQueue-0] (_SQLEngine.java:1220_) - Loading class: > com.mapping.MapCableMaterial using SQL: > [EMAIL PROTECTED] > > inside Test_table:jdoSetTimeStamp():1138280152494 > > DEBUG [AWT-EventQueue-0] (_LockEngine.java:396_) - Loading class: > com.mapping.MapCableMaterial with id: AL > > DEBUG [AWT-EventQueue-0] (_LockEngine.java:396_) - Loading class: > com.mapping.MapCable with id: MCN10 > > INFO [AWT-EventQueue-0] (_MapCable.java:95_) - Load done. > > > > Best regards, > > > > Manuel > > > [email protected] schrieb am 20.01.06 18:30:37: > > > Hi Manuel, > > have a look at: > > http://castor.codehaus.org/api/org/exolab/castor/jdo/Database.html#load(java.lang.Class,%20java.lang.Object,%20java.lang.Object) > > if this is what you wanted to. > > Regards > Ralf > Castor JDO, committer > > > Manuel Castrillon schrieb: >> Hello all. >> >> I have made a wrapper for Castor but when I preform a load I am faced >> with the following dilemma. >> >> A new instance of my Object is created when I do load(), I realize that >> this would not be a problem in C++ because I could pass by >> reference...but in Java I really do not know how to go about this. >> >> Something like Cloneable would be nice but it is private... Here is my > code: >> >> >> >> CastorWrapper castorWrapper = new CastorWrapper(); >> Cable c= new Cable(); >> >> >> //set required parameters >> >> c=castorWrapper.doLoad(db1,pk,c); >> >> >> >> public class CastorWrapper { >> >> public Cable doLoad(Database db, Object pk, Cable genObj) >> throws Exception >> { >> &nbs! p; //Cable clone=(Cable)genObj.clone(); //would be perfect!!!! >> >> try { >> //Ideally this would be the exact same instance, but obviously NOT >> genObj=(Cable)db.load(genObj.getClass(),pk); >> } >> catch (PersistenceException pe) { >> log4jCat.error("DB load failed.", pe); >> db.rollback(); >> } >> return genObj; >> } >> >> } >> >> >> >> All suggestions would be greatly appreciated.... >> >> >> >> Regards, >> >> Manuel >> >> >> >> >> >> >> >> Verschicken Sie romantische, coole und witzige Bilder per SMS! >> Jetzt bei WEB.DE FreeMail: *http://f.web.de/?mc=021193* >> > > -- > > Syscon Ingenieurbüro für > Meß- und Datentechnik GmbH > Ralf Joachim > Raiffeisenstraße 11 > D-72127 Kusterdingen > Germany > > Tel. +49 7071 3690 52 > Mobil: +49 173 9630135 > Fax +49 7071 3690 98 > > Email: [EMAIL PROTECTED] > Web: www.syscon-world.de > > ------------------------------------------------- > If you wish to unsubscribe from this list, please > send an empty message to the following address: > > [EMAIL PROTECTED] > ------------------------------------------------- > > > > > XXL-Speicher, PC-Virenschutz, Spartarife & mehr: Nur im WEB.DE Club! > Jetzt gratis testen! *http://freemail.web.de/home/landingpad/?mc=021130* > ------------------------------------------------- If you wish to unsubscribe from this list, please send an empty message to the following address: [EMAIL PROTECTED] -------------------------------------------------

