You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Henrik Berg <he...@ifi.uio.no> on 2003/03/21 11:22:31 UTC
Do I have to supply getXXX() and setXXX(...)-methods?
Hi!
Simple question: If I want to use OJB, do I have to make public
set/get-methods for all the fields I want to store in the database?
--
Henrik
Re: Do I have to supply getXXX() and setXXX(...)-methods?
Posted by Will Jaynes <ja...@umich.edu>.
No you don't. Use the following setting in the OJB.properties file:
PersistentFieldClass=org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDefaultImpl
This assumes that your repository.xml mapping is based on fields in your
classes.
Henrik Berg wrote:
> Hi!
>
> Simple question: If I want to use OJB, do I have to make public
> set/get-methods for all the fields I want to store in the database?
>
[newbie] Retrieving the same object several times
Posted by Henrik Berg <he...@ifi.uio.no>.
Didn't find anything about this in the tutorials, but it's probably
quite simple:
Say I do this:
Person example = new Person();
example.setId(1); // id is primary key
Query query = new QueryByCriteria(example);
Person per = (Person)broker.getObjectByQuery(query);
And then, at some later point, I do this:
Person example2 = new Person();
example2.setId(1); // id is primary key
Query query2 = new QueryByCriteria(example2);
Person per2 = (Person)broker.getObjectByQuery(query2);
At this point, will (per == per2)? A few simple tests indicate that
this is the case, but can I rely on it? If not, under which
circumstances will I get (per != per2) from this?
--
Henrik