Hi,

Florin Pop wrote:

Hi Oliver,

if I used the p6spy I can see that Hibernate generates a huge sql statement
using joins, and OJB creates many smaller queries without joins.


> OJB:
> SELECT ID,id_street,FIRSTNAME,birthplace,birthday,NAME,citizenship FROM
> PERSON WHERE ID = ?
...
> Hibernate:                 
> select city1_.id as id0_, city1_.name as name0_, city1_.id_county as
...
> wow
indeed cool!
By the way, is this the sql query for hibernate logged by
p6spy - oddly SQL?

is this also configurable on OJB?


No, I don't think OJB support to materialize a full objects hierachy by one select.


> 1. If I set the attribute auto-retrieve="true" all the loads work slower. If
> I set it to "false" then there is a speed up but when I try to access the
> Collection of the counties I receive NullPointerException. How do I init the
> collection?


You can use PersistenceBroker#retrieveAllReferences
or PersistenceBroker#retrieveReference method to get
references by hand.


>Is it mandatory to use proxy for County? >

If you want to do lazy-materialization - yes.


> 2. In the County class, initially I wanted to have no id_country field, the
> country field contains also an id; But I was unable to map the country
> object without introducing that field. How can I overcome this situation?
>


Use a 'anomynous field' add access="anonymous" to field-descriptor
of id_country. See
http://db.apache.org/ojb/howto-use-anonymous-keys.html


> 3. Once again thank you for your patience. no problem!

regards,
Armin








Maybe it is helpfull to describe a little bit my testing database structure:

- there are countries in COUNTRY table, a country has counties in COUNTY, a
county has cities in CITY, a city has zipcodes in ZIPCODE, a zipcode has
streets in STREET.
- there are 20 milion persons in PERSON table, having a birthplace(foreign
key to CITY), an address (foreign key to STREET), a citizenship (foreign key
to COUNTRY) plus some other details stored in the columns of the PERSON
table

Beeing a rookie in OJB it is possible that my mappings are not the best.

Thanks for your quick feedback.

Regards,

Florin

PS: I have another questions about lazy-loading and mappings. In my Country
class I defined a counties filed which stores the counties in that country.

<class-descriptor class="florinp.Country" table="COUNTRY">
    <field-descriptor name="id" column="ID" jdbc-type="BIGINT"
        primarykey="true" autoincrement="true"/>

<field-descriptor name="name" column="NAME" jdbc-type="VARCHAR"/>

<field-descriptor name="iso2" column="iso2" jdbc-type="CHAR"/>

<field-descriptor name="iso3" column="iso3" jdbc-type="CHAR"/>

    <collection-descriptor name="counties"
element-class-ref="florinp.County" auto-retrieve="false"
        orderby="id" sort="DESC">
        <inverse-foreignkey field-ref="id_country"/>
    </collection-descriptor>

</class-descriptor>

<class-descriptor class="florinp.County" table="COUNTY">
    <field-descriptor name="id" column="ID" jdbc-type="BIGINT"
        primarykey="true" autoincrement="true"/>

<field-descriptor name="name" column="NAME" jdbc-type="VARCHAR"/>

<field-descriptor name="code" column="code" jdbc-type="CHAR"/>

    <field-descriptor name="id_country" column="id_country"
jdbc-type="BIGINT"/>

    <reference-descriptor name="country"
        class-ref="florinp.Country">
        <foreignkey field-ref="id_country"/>
    </reference-descriptor>

    <collection-descriptor name="cities" element-class-ref="florinp.City"
auto-retrieve="false"
        orderby="id" sort="DESC">
        <inverse-foreignkey field-ref="id_county"/>
    </collection-descriptor>

</class-descriptor>

1. If I set the attribute auto-retrieve="true" all the loads work slower. If
I set it to "false" then there is a speed up but when I try to access the
Collection of the counties I receive NullPointerException. How do I init the
collection? Is it mandatory to use proxy for County?

2. In the County class, initially I wanted to have no id_country field, the
country field contains also an id; But I was unable to map the country
object without introducing that field. How can I overcome this situation?


3. Once again thank you for your patience.


-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Tuesday, November 04, 2003 5:51 PM To: [EMAIL PROTECTED] Subject: RE: Loading an object


Hello Florin,



-----Original Message-----
From: Florin Pop [mailto:[EMAIL PROTECTED]


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


[..]

I would expect OJB to generate roughly the same
SQL statement. Provided that the execution of the SQL
dominates (which is questionable as Thomas and Armin
pointed out), I would expect about the same performance.


Could you please capture the executed SQL statements
of both tests?  I really would like to see if
they differ.  I cannot imagine what Hibernate
does so much differently.

(Please refer to FAQ "How can I trace and/or profile SQL statements executed by OJB?"
in http://db.apache.org/ojb/faq.html. The instructions
should work for Hibernate, too.)


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