On Saturday 29 May 2004 10.33, Werner Guttmann wrote:
> On Sat, 29 May 2004 00:17:15 +0200, Stefan Frank wrote:
(...)
> >Because we are developing a three tier client, we can't use caching. The
> > cache is disabled and we are requesting every object direct from the
> > database. As a consequence we must lock a record on the database as soon
> > as we want to modify the desired object (the business-layer is
> > distributed on different machines).
> >
> >I tried to load the object with access-mode (short)3.
> >
> >But then PostgreSQL complains:
> ><---------------------------------------------------------------------->
> >May 28, 2004 11:47:31 PM org.exolab.castor.jdo.engine.SQLEngine load
> >SEVERE: A fatal error occurred while loading
> >ch.fhz.hta.dbsa.server.entities.Organization using SQL: SELECT
> >"room"."room_id","organization"."address","organization"."city","organizat
> >ion"."contact_person_department","organization"."contact_person_first_n
>
> ame","organization"."contact_person_last_name","organization"."contact_pers
>on_telefon_number","organization"."fax_number","organization"."nam
> e","organization"."organization_size","organization"."short_name","organiza
>tion"."telefon_number","organization"."zip_code","organization"."is_delet
> ed","organization"."last_edited"
>
> >FROM "organization" LEFT OUTER JOIN "room" ON
> >"organization"."organization_id"="room"."organization_id" WHERE
> >"organization"."organization_id"=? FOR UPDATE
> >org.postgresql.util.PSQLException: ERROR: SELECT FOR UPDATE cannot be
> > applied to the nullable side of an outer join
> ><---------------------------------------------------------------------->
> >The problem is obviously, that the Organization-Object holds a collection
> > of Rooms (a reference would also lead to the error). But as long as this
> > collection is empty (or the reference is null), PostgreSQL complains
> > about the nullable side of the outer join.
> >
> >Is there any solution available?
> >
> >And my last question is about lazy loading.
> >I have the Room class with a relation (1:1) to the Organization class.
>
> Well, actually you happen to have a 1:M relation here, correct ?

That's true. Certainly it is a (1:M) relation. A organization can have M 
rooms, but a room can only have one organization associated. I just found 
out, that I missinterpreted the documentation. How can I define a 
lazy-loading on a reference? I mean the Room-class doesn't have a collection 
of Organization, it only has a reference.
I thought that I must use instead a collection. And that's probably the only 
solution I guess? But do I have to create a seperate table for the N:M 
relation (although it's only a 1:M relation?).

Is there any better solution?
>
> ><---------------------------------------------------------------------->
> >class Room {
> >  private Collection m_oOrganization;
> >(...)
> >  public void setM_oOrganization (Collection organization) {}
> >  public Collection getM_oOrganization ()
> >}
> ><---------------------------------------------------------------------->
> >class Organization { (..) }
> ><---------------------------------------------------------------------->
> ><class name="Room" (...)>
> >             <map-to table="room" />
> >             <cache-type type="none" />
> >             <field name="m_oOrganization" type="Organization" lazy="true"
> >collection="collection">
> >                     <sql name="organization_id" />
>
>                                                ^^^^^^^^^^^^^^^^^^^^^^^^
>
> >             </field>
> >(...)
> ><---------------------------------------------------------------------->
> >As soon as I call the create(Object)-method and pass a Room-object
> >I receive following error:
> ><---------------------------------------------------------------------->
> >org.exolab.castor.jdo.PersistenceException: Nested error:
> >java.lang.NumberFormatException: For input string: "[]"
> >     at
> >org.exolab.castor.persist.TransactionContext.create(TransactionContext.jav
> >a:921) at
> > org.exolab.castor.jdo.engine.DatabaseImpl.create(DatabaseImpl.java:363)
> > at
> > ch.fhz.hta.dbsa.server.db.ModifyBroker.createRoom(ModifyBroker.java:177)
> > <---------------------------------------------------------------------->
>
> ^
> I think that the problem here is with the way the <sql> element is defined.
> In this definition, you have to point to the 'many-key' portion of the
> primary key of M_oOrganization (assuming that such a class exists). Iow,
>
> <field name="m_oOrganization" type="Organization" lazy="true"
> collection="collection"> <sql name="organization_id" />
> </field>
>
> should change to
>
> <field name="m_oOrganization" type="Organization" lazy="true"
> collection="collection"> <sql many-key="room_id" />
> </field>
>
>
> assuming that the table definition for M_oOrganization includes a column
> 'room_id' that is part of the primary key.
>
> >Regards,
> >
> >Stefan
> >
> >
> >
> >
> >
> >-----------------------------------------------------------
> >If you wish to unsubscribe from this mailing, send mail to
> >[EMAIL PROTECTED] with a subject of:
> >        unsubscribe castor-user
>
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
>         unsubscribe castor-user



----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-user

Reply via email to