Hi Florin,

<snip>
> 
> Regards,
> Florin
> 
> PS: I have another question: is it possible in OJB to map an 
> object field to
> a calculated value. For example I have a birthday column in 
> PERSON table and
> I want to have in the Person class a field age containing the 
> age of the
> person(
> age = currentDate - birthday, or something like this)

There are several ways to achieve this.
1. instance callbacks. you can implement a hook method that calculates the
age attribute on loading the instance from the DB.
(see http://db.apache.org/ojb/tutorial3.html#instance%20callbacks)
2. you could use a FieldConversion to to the Job
(http://db.apache.org/ojb/jdbc-types.html#defining%20type-%20and%20value%20c
onversions)
3. you could also use a nested Object approach
(http://db.apache.org/ojb/tutorial3.html#nested%20objects)
4. you could use a RowReader
(http://db.apache.org/ojb/tutorial3.html#using%20rowreaders)

I depends a lot on the context which is the best solution. In general I
consider 2) and 3) to be easier to use for this scenario.

Thomas


> 
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, November 04, 2003 2:22 PM
> To: [EMAIL PROTECTED]
> Subject: RE: Loading an object
> 
> 
> Hello,
> 
> > -----Original Message-----
> > From: Florin Pop [mailto:[EMAIL PROTECTED]
> 
> >  I tried:
> > 
> >         Criteria crit = new Criteria();
> >         crit.addEqualTo("id", new Long(PERSON_ID));
> >         Query query = new QueryByCriteria(Person.class, crit);
> >         Person person = (Person) broker.getObjectByQuery(query);
> > 
> > but it works very slow, 6-8 times slower than in Hibernate:
> 
> I do not believe that. 
> 
> [..]
> 
> > Is there another way for doing this in OJB? 
> 
> try:
> 
> Identity id = new Identity(Person.class, Person.class, 
>                   new Long[] {new Long(PERSON_ID)});
> PersistenceBroker.getObjectByIdentity(id);
> 
> 
> Olli
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to