[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: copyObject()
On Tue, 25 Jan 2000, you wrote:
> Hi,
>
> i'm trying to use the copyObject() for clone a
> persistent object.
> I tried to change the 'simple' example in this way:
>
> ....
>
> Auto dadix = (Auto) db.copyObject( auto );
> dadix.setAge( new Integer(916));
> dadix.print();
> auto.print();
> ....
>
> The output is:
> Auto: Ford,916 (dadix)
> Auto: Ford,916 (auto)
>
> The object still be the same. There i did something
> wrong? or there is a bug?
I've tested this with the following, slightly enhanced, code from the "simple"
sample.
--- Client.java -------------------------------
public static void main (String[] args) throws Exception {
RemoteDatabase db = new RemoteDatabase();
db.open ("localhost", 3333);
db.reloadClasses();
System.out.println ("connected...");
Auto auto = (Auto)db.objectForName ("auto");
if (auto == null)
auto = (Auto)db.createObject (AutoImpl.class.getName(), Database.Private, "auto");
// doSomething() returns the database object itself. However, in the
// client we get a proper proxy object.
Auto auto2 = (Auto)auto.doSomthing (auto);
System.out.println ("auto:" + auto);
auto.setAge (new Integer(3));
System.out.println ("auto.setAge (3)");
// auto and auto2 are proxies of the same object.
System.out.println ("auto2:" + auto2);
Auto copy = (Auto)db.copyObject (auto);
copy.setAge (new Integer(100));
System.out.println ("\nauto:" + auto);
System.out.println ("copy:" + copy);
db.deleteObject (auto);
db.close();
System.out.println ("deconnected...");
}
-------------------------------
I get the following output:
connected...
auto:Auto:Ford, 0
auto2:Auto:Ford, 3
auto:Auto:Ford, 3
copy:Auto:Ford, 100
deconnected...
Which is correct. I did only test with my current development version. Please
check the above code with 0.3.3.
Falko
--
______________________________________________________________________
Falko Braeutigam mailto:falko@softwarebuero.de
softwarebuero m&b (SMB) http://www.softwarebuero.de