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