Hi again,

as Thomas mentioned the test seems not fair,
because first time a PB instance start to work
behind the scenes some inital startup stuff
is done (read metadata, setup connection pool, ...)

I made some tests to demonstrate the
difference. I lookup three different
persons (thus no caching could be used)

result: eugen
591 ms
result: frido
10 ms
result: guido
10 ms

Thus to make the test more fair, lookup
a "dummy object" to allow complete startup
of both frameworks and then perform your test.

regards,
Armin

Mahler Thomas wrote:
Hi Florin,

IMO it makes not much sense to compare the performance of two persistence
engines based on such a simplified test.
You must test things like working with real world object models,
with high loads over a longer period of time,
multi user access scenarios, etc.

I don't know about Hibernate, but OJB at least has a "warming up" phase.
So for this simple test hings will look differenet if you perform it in a
loop with say 10 000 iterations!

cu,
Thomas


-----Original Message-----
From: Florin Pop [mailto:[EMAIL PROTECTED]
Sent: Tuesday, November 04, 2003 3:09 PM
To: '[EMAIL PROTECTED]'
Subject: RE: Loading an object


Hi bellow are the 2 methods


public void testLoadPersonUsingOJB() throws Exception {
long time = System.currentTimeMillis();
final long PERSON_ID = 112327;
Person person = new Person();
Identity id = new Identity(Person.class, Person.class, new Long[]
{new Long(PERSON_ID)});
person = (Person) broker.getObjectByIdentity(id);
assertTrue(person != null);
assertTrue(null != person.getBirthday());
assertTrue(null != person.getCitizenship());
assertTrue(null != person.getCity());
assertTrue(null != person.getFirstName());
assertTrue(null != person.getName());
assertTrue(null != person.getStreet());
time = System.currentTimeMillis() - time;
System.out.println(time);
}


public void testLoadPersonUsingHibernate() throws Exception {
       long time = System.currentTimeMillis();
       final long PERSON_ID = 112327;
       Person person = (Person) session.load(Person.class, new
Long(PERSON_ID));
       assertTrue(person != null);
       assertTrue(null != person.getBirthday());
       assertTrue(null != person.getCitizenship());
       assertTrue(null != person.getCity());
       assertTrue(null != person.getFirstName());
       assertTrue(null != person.getName());
       assertTrue(null != person.getStreet());
       assertTrue(null != person.getFullName());
       time = System.currentTimeMillis() - time;
       System.out.println(time);
}

the session(4 hibernate) and the broker (4 OJB) are initialized in the
constructors.


Regards,


florin

-----Original Message-----
From: Armin Waibel [mailto:[EMAIL PROTECTED]
Sent: Tuesday, November 04, 2003 3:40 PM
To: OJB Users List
Subject: Re: Loading an object


Hi,


Florin Pop wrote:


Hi again,

I have tried your suggested approach but curiously the same result.

The tests that I run consist just in loading an Person

object from the data

source. Both with Hibernate and with OJB I use no cache and

this load


operation is the first and only one opperation that I execute in one
session. So there is no object cached anywhere.

For me is also very surprizing the result.


For me too!


How does your test looks like?

long time = System.currentTimeMillis();
Person person = (Person) broker.getObjectByQuery(query);
time = System.currentTimeMillis() - time;

Can you post source of both test?

regards,
Armin



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)


-----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]

---------------------------------------------------------------------
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