Thank you very much for the remark with the lower case obj ref. 
What should I say: It seems to have solved the problem -- and produced another 
one :-(
But after seeing the same output for much too long I consider this one a 
success :-)

This is the console output (I have attached the Java Source code as well, 
sorry, if this gets a bit lengthy):

[org.apache.ojb.odmg.TransactionImpl] ERROR: Locking obj null with lock mode 1 
failed
null
java.lang.ArrayIndexOutOfBoundsException
        at 
org.apache.ojb.broker.metadata.ClassDescriptor.getFieldDescriptorByIndex(Unknown 
Source)
        at 
org.apache.ojb.broker.metadata.ObjectReferenceDescriptor.getForeignKeyFieldDescriptors(Unknown
 
Source)
        at org.apache.ojb.odmg.TransactionImpl.lockCollections(Unknown Source)
        at org.apache.ojb.odmg.TransactionImpl.register(Unknown Source)
        at org.apache.ojb.odmg.TransactionImpl.lock(Unknown Source)
        at org.apache.ojb.odmg.TransactionImpl.lockReferences(Unknown Source)
        at org.apache.ojb.odmg.TransactionImpl.register(Unknown Source)
        at org.apache.ojb.odmg.TransactionImpl.lock(Unknown Source)
        at org.apache.ojb.odmg.oql.OQLQueryImpl.execute(Unknown Source)
        at net.uhrhan.musicdb.Application.run(Application.java:82)
        at net.uhrhan.musicdb.Application.main(Application.java:57)
java.lang.ArrayIndexOutOfBoundsException
        at 
org.apache.ojb.broker.metadata.ClassDescriptor.getFieldDescriptorByIndex(Unknown 
Source)
        at 
org.apache.ojb.broker.metadata.ObjectReferenceDescriptor.getForeignKeyFieldDescriptors(Unknown
 
Source)
        at org.apache.ojb.odmg.TransactionImpl.lockCollections(Unknown Source)
        at org.apache.ojb.odmg.TransactionImpl.register(Unknown Source)
        at org.apache.ojb.odmg.TransactionImpl.lock(Unknown Source)
        at org.apache.ojb.odmg.TransactionImpl.lockReferences(Unknown Source)
        at org.apache.ojb.odmg.TransactionImpl.register(Unknown Source)
        at org.apache.ojb.odmg.TransactionImpl.lock(Unknown Source)
        at org.apache.ojb.odmg.oql.OQLQueryImpl.execute(Unknown Source)
        at net.uhrhan.musicdb.Application.run(Application.java:82)
        at net.uhrhan.musicdb.Application.main(Application.java:57)
null
[org.apache.ojb.odmg.TransactionImpl] ERROR: Locking obj -- with lock mode 1 
failed
null
org.odmg.LockNotGrantedException
        at org.apache.ojb.odmg.TransactionImpl.lock(Unknown Source)
        at org.apache.ojb.odmg.TransactionImpl.lockReferences(Unknown Source)
        at org.apache.ojb.odmg.TransactionImpl.register(Unknown Source)
        at org.apache.ojb.odmg.TransactionImpl.lock(Unknown Source)
        at org.apache.ojb.odmg.oql.OQLQueryImpl.execute(Unknown Source)
        at net.uhrhan.musicdb.Application.run(Application.java:82)
        at net.uhrhan.musicdb.Application.main(Application.java:57)
org.odmg.LockNotGrantedException
        at org.apache.ojb.odmg.TransactionImpl.lock(Unknown Source)
        at org.apache.ojb.odmg.TransactionImpl.lockReferences(Unknown Source)
        at org.apache.ojb.odmg.TransactionImpl.register(Unknown Source)
        at org.apache.ojb.odmg.TransactionImpl.lock(Unknown Source)
        at org.apache.ojb.odmg.oql.OQLQueryImpl.execute(Unknown Source)
        at net.uhrhan.musicdb.Application.run(Application.java:82)
        at net.uhrhan.musicdb.Application.main(Application.java:57)
null
Exception in thread "main" org.odmg.LockNotGrantedException
        at org.apache.ojb.odmg.TransactionImpl.lock(Unknown Source)
        at org.apache.ojb.odmg.oql.OQLQueryImpl.execute(Unknown Source)
        at net.uhrhan.musicdb.Application.run(Application.java:82)
        at net.uhrhan.musicdb.Application.main(Application.java:57)


public class Artist
{
        private Integer _id;
        private String _name;
        private Integer _since;
        private Integer _until;
        private List _songs;

        public Artist()
        {
                _songs = new ArrayList();
        }

        /**
         * Returns the id.
         * @return Integer
         */
        public Integer getId()
        {
                return _id;
        }

        /**
         * Returns the name.
         * @return String
         */
        public String getName()
        {
                return _name;
        }

        /**
         * Returns the since.
         * @return Integer
         */
        public Integer getSince()
        {
                return _since;
        }

        /**
         * Returns the until.
         * @return Integer
         */
        public Integer getUntil()
        {
                return _until;
        }

        /**
         * Sets the id.
         * @param id The id to set
         */
        public void setId(Integer id)
        {
                _id = id;
        }

        /**
         * Sets the name.
         * @param name The name to set
         */
        public void setName(String name)
        {
                _name = name;
        }

        /**
         * Sets the since.
         * @param since The since to set
         */
        public void setSince(Integer since)
        {
                _since = since;
        }

        /**
         * Sets the until.
         * @param until The until to set
         */
        public void setUntil(Integer until)
        {
                _until = until;
        }

        public String toString()
        {
                return this._name;
        }
        /**
         * Returns the songs.
         * @return List
         */
        public List getSongs()
        {
                return _songs;
        }

        /**
         * Sets the songs.
         * @param songs The songs to set
         */
        public void setSongs(List songs)
        {
                _songs = songs;
        }

}



public class Song
{
        private Integer _id;
        private String _title;
        private Integer _artistid;
        private Artist _artist;

        public Song()
        {
                _artist = new Artist();
                
        }

        /**
         * Returns the artist.
         * @return Artist
         */
        public Artist getArtist()
        {
                return _artist;
        }

        /**
         * Returns the artistid.
         * @return Integer
         */
        public Integer getArtistid()
        {
                return _artistid;
        }

        /**
         * Returns the id.
         * @return Integer
         */
        public Integer getId()
        {
                return _id;
        }

        /**
         * Returns the title.
         * @return String
         */
        public String getTitle()
        {
                return _title;
        }

        /**
         * Sets the artist.
         * @param artist The artist to set
         */
        public void setArtist(Artist artist)
        {
                _artist = artist;
        }

        /**
         * Sets the artistid.
         * @param artistid The artistid to set
         */
        public void setArtistid(Integer artistid)
        {
                _artistid = artistid;
        }

        /**
         * Sets the id.
         * @param id The id to set
         */
        public void setId(Integer id)
        {
                _id = id;
        }

        /**
         * Sets the title.
         * @param title The title to set
         */
        public void setTitle(String title)
        {
                _title = title;
        }

        public String toString()
        {
                return this._title;
        }
}


On Wednesday 25 September 2002 12:35, Chris Lewington wrote:
> Hi Christoph,
>
> You also need to post your class code - there may be a mismatch between
> what is in your java source and what is in your repository xml file (which
> by the way looks OK to me syntax-wise). According to your xml file, it
> looks as though you want to have an Artist obj ref in your Song class - if
> that is not the case then your class/repository details will be out of
> sync. Also (small point) you specified the obj ref field as "Artist", but a
> common java convention is to have obj refs starting with lower case (class
> names with upper case) - may avoid confusion when reading the code.
>
> Cheers,
>
> (another) Chris
>
> Christoph Uhrhan wrote:
> > Sorry, but this doesn't work, either.
> > The error message appears none the less.
> > Maybe the stack trace is of help for you!
> >
> > Thank you for your help
> > Christoph
> >
> > [BOOT] INFO: OJB.properties:
> > file:/home/chris/java/projects/ojb/bin/OJB.properties
> > [org.apache.ojb.broker.ta.PersistenceBrokerFactoryDefaultImpl] INFO:
> > Already created persistence broker instances: 0
> > [org.apache.ojb.broker.util.sequence.SequenceManagerFactory] INFO: Use
> > sequence manager class: class
> > org.apache.ojb.broker.util.sequence.SequenceManagerHiLoImpl
> > [org.apache.ojb.broker.ta.PersistenceBrokerFactoryDefaultImpl] INFO:
> > Already created persistence broker instances: 1
> > [org.apache.ojb.broker.accesslayer.AbstractPoolableConnectionFactory]
> > INFO: # Create connection pool for JdbcDescriptorKey -452004565 #
> > [org.apache.ojb.broker.accesslayer.AbstractConnectionFactory] INFO: #
> > Already created connections: 1 returning :
> > org.postgresql.jdbc2.Connection@195d80
> > [org.apache.ojb.broker.ta.PersistenceBrokerFactoryDefaultImpl] INFO:
> > Already created persistence broker instances: 2
> > [org.apache.ojb.broker.accesslayer.AbstractConnectionFactory] INFO: #
> > Already created connections: 2 returning :
> > org.postgresql.jdbc2.Connection@4e5b1c
> > [org.apache.ojb.broker.ta.PersistenceBrokerFactoryDefaultImpl] INFO:
> > Already created persistence broker instances: 3
> > org.apache.ojb.broker.metadata.MetadataException: Error creating
> > PersistentField: net.uhrhan.musicdb.data.Song, Artist at
> > org.apache.ojb.broker.metadata.PersistentFieldFactory.createPersistentFie
> >ld(Unknown Source) at
> > org.apache.ojb.broker.metadata.AttributeDescriptorBase.getPersistentField
> >(Unknown Source) at
> > org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.retrieveReference(Un
> >known Source) at
> > org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.retrieveReferences(U
> >nknown Source) at
> > org.apache.ojb.broker.accesslayer.RsIterator.getObjectFromResultSet(Unkno
> >wn Source) at org.apache.ojb.broker.accesslayer.RsIterator.next(Unknown
> > Source) at
> > org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuery
> >(Unknown Source) at
> > org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuery
> >(Unknown Source) at
> > org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuery
> >(Unknown Source) at org.apache.ojb.odmg.oql.OQLQueryImpl.execute(Unknown
> > Source) at net.uhrhan.musicdb.Application.run(Application.java:82) at
> > net.uhrhan.musicdb.Application.main(Application.java:57)
> > [org.apache.ojb.broker.accesslayer.RsIterator] ERROR: Error creating
> > PersistentField: net.uhrhan.musicdb.data.Song, Artist
> > org.apache.ojb.broker.metadata.MetadataException: Error creating
> > PersistentField: net.uhrhan.musicdb.data.Song, Artist at
> > org.apache.ojb.broker.metadata.PersistentFieldFactory.createPersistentFie
> >ld(Unknown Source) at
> > org.apache.ojb.broker.metadata.AttributeDescriptorBase.getPersistentField
> >(Unknown Source) at
> > org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.retrieveReference(Un
> >known Source) at
> > org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.retrieveReferences(U
> >nknown Source) at
> > org.apache.ojb.broker.accesslayer.RsIterator.getObjectFromResultSet(Unkno
> >wn Source) at org.apache.ojb.broker.accesslayer.RsIterator.next(Unknown
> > Source) at
> > org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuery
> >(Unknown Source) at
> > org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuery
> >(Unknown Source) at
> > org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuery
> >(Unknown Source) at org.apache.ojb.odmg.oql.OQLQueryImpl.execute(Unknown
> > Source) at net.uhrhan.musicdb.Application.run(Application.java:82) at
> > net.uhrhan.musicdb.Application.main(Application.java:57) Exception in
> > thread "main" java.util.NoSuchElementException
> >         at org.apache.ojb.broker.accesslayer.RsIterator.next(Unknown
> > Source) at
> > org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuery
> >(Unknown Source) at
> > org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuery
> >(Unknown Source) at
> > org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuery
> >(Unknown Source) at org.apache.ojb.odmg.oql.OQLQueryImpl.execute(Unknown
> > Source) at net.uhrhan.musicdb.Application.run(Application.java:82) at
> > net.uhrhan.musicdb.Application.main(Application.java:57)
> >
> > On Tuesday 24 September 2002 21:20, Dave Derry wrote:
> > > 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]>


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

Reply via email to