Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Antw.: [eclipselink-users] question about readObject(Object object) method in Session class

Hi Bozhou,

what is the primary key of your Employee object?
And do you have the log output for this bit of code? You should be able to see the SQL that was issued.

regards,

Jaap

----- Oorspronkelijk bericht -----
Van: bozhou.tao@xxxxxxxxxxx
Aan: eclipselink-users@xxxxxxxxxxx
Verzonden: Dinsdag 27 juli 2010 04:02:15 GMT +01:00 Amsterdam / Berlijn / Bern / Rome / Stockholm / Wenen
Onderwerp: [eclipselink-users] question about readObject(Object object) method in Session class

Hi,

I'm now using Eclipselink as the persistence provider of Toplink in my project and for some reason I need to use the readObject(Object object) method of the Session class.
According to the document:
java.lang.Object readObject(java.lang.Object object)
                            throws DatabaseException
PUBLIC: Use the example object to construct a read object query by the objects primary key. This will read the object from the database with the same primary key as the object or null if no object is found.
However, when I call this method in my code, the result is not as I expected. Take the code below for example:

Employee e = new Employee();
e.setEmployeeId(2);
Employee eCopy = session.readObject(e);
System.out.print(eCopy.getEmployeeId());

I think the result should be "2" but the result I get is "1".

Is it design! ed to be that?

Regards,
Bozhou



Hotmail: Trusted email with powerful SPAM protection. Sign up now.

Back to the top