Hi Dave,

Great news! Together with the changes proposed by Chris Lewington it works 
like a charm!
After trying the same over and over again I think I was kind of blindsighted, 
I guess would not have come out this alone. 

Dave and Chris, thank you very much for your help.

Cheers
Christoph


On Wednesday 25 September 2002 19:37, Dave Derry wrote:
> Despite appearances, I am not responding to myself. I received Christoph's
> response to this post at home last night, so it is not available to me for
> responding.   ;-}
>
> Anyway, Christoph I'm not sure what you tried, and I am by NO means expert
> with OJB, but I think that your class-descriptor for
> net.uhrhan.musicdb.data.Artist needs a collection-descriptor like this:
>
>       <collection-descriptor
>          name="songs"
>          element-class-ref="net.uhrhan.musicdb.data.Song"
>
>
> and your Artist class needs a Collection attribute 'songs'. (I just noticed
> this last requirement)
>
> Hopefully this will help. If this is what you have already tried, post that
> info back to the list and maybe someone who knows more than I do will
> respond.
>
> Dave Derry
>
>
> ----- Original Message -----
> From: "Dave Derry" <[EMAIL PROTECTED]>
>
> > If your setup looks exactly like the tutorial, you're looking at the
> > wrong part of the tutorial.  ;-}
> >
> > Look at the 'mapping 1:n associations'> You need a collection-descriptor
>
> in
>
> > the class descriptor for artist, since an artist will have a collection
> > of songs.
> >
> > Hope this helps,
> > Dave Derry
> >
> > ----- Original Message -----
> > From: "Christoph Uhrhan" <[EMAIL PROTECTED]>
> >
> >
> > Hello,
> > I have a problem with foreign key references. I've been searching the
> > list but
> > didn't find an answer, so I'm rather desperate.
> > I have OJB running on a PostgreSQL-Database and a fairly simple example
>
> that
>
> > just won't work.
> >
> > These are the tables:
> >
> > create table artist
> > (
> >   artistid serial primary key,
> > name varchar(300),
> > since int,
> > until int
> > );
> >
> > create table song
> > (
> >   songid serial primary key,
> > title varchar(500) not null,
> > artistid int references artist,
> > mp3genreid int references mp3genre,
> > year int
> > );
> >
> > This is the mapping:
> >
> > <class-descriptor
> > class="net.uhrhan.musicdb.data.Artist"
> > table="artist"
> >
> > <field-descriptor id="1"
> > name="id"
> > column="artistid"
> > jdbc-type="INTEGER"
> > primarykey="true"
> > autoincrement="true"
> > />
> > <field-descriptor id="2"
> > name="name"
> > column="name"
> > jdbc-type="VARCHAR"
> > />
> > <field-descriptor id="3"
> > name="since"
> > column="since"
> > jdbc-type="INTEGER"
> > />
> >
> > <field-descriptor id="4"
> > name="until"
> > column="until"
> > jdbc-type="INTEGER"
> > />
> > </class-descriptor>
> >
> >
> > <class-descriptor
> > class="net.uhrhan.musicdb.data.Song"
> > table="song"
> >
> > <field-descriptor id="1"
> > name="id"
> > column="songid"
> > jdbc-type="INTEGER"
> > primarykey="true"
> > autoincrement="false"
> > />
> > <field-descriptor id="2"
> > name="title"
> > column="title"
> > jdbc-type="VARCHAR"
> > />
> > <field-descriptor id="3"
> > name="artistid"
> > column="artistid"
> > jdbc-type="INTEGER"
> > />
> > <reference-descriptor
> > name="Artist"
> > class-ref="net.uhrhan.musicdb.data.Artist"
> >
> > <foreignkey field-id-ref="3"/>
> > </reference-descriptor>
> > </class-descriptor>
> >
> > And querying via the ODMG-API and the PersistenceBroker-API I get the
> > following error-Message:
> >
> > org.apache.ojb.broker.metadata.MetadataException: Error creating
> > PersistentField: net.uhrhan.musicdb.data.Song, Artist
> >
> > What am I doing wrong? The setup looks exactly like that presented in the
> > 'Advanced O/R-Mapping'-Tutorial.
> >
> > Thanks in advance for your help (and your patience)
> > Cheers
> > Christoph


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

Reply via email to