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]