the errors came only after i added the DTD definition. a warning: please
specify a DTD so i can verify the schema would have been nice. ;)

bye
fabian

On Sun, 2002-01-27 at 00:20, John McNally wrote:
> I was going to suggest that you try defining your fk's after all the
> columns, but I assumed that since you did not mention any errors wrt
> parsing the xml, that it was handled ok.
> 
> Since you are using the defaultIdMethod attribute, you should add
> idMethod="none" to tables that do not have generated keys.  e.g.
> ARTIST_HAS_WEBSITE.  These attributes do not affect the sql, but they do
> affect the object model.
> 
> john mcnally
> 
> Fabian Moerchen wrote:
> > 
> > hi
> > 
> > pete solved the problem after trying my code:
> > 
> > you should always start the schema definition with
> > 
> > <?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
> > <!DOCTYPE database SYSTEM
> > "http://jakarta.apache.org/turbine/dtd/database.dtd";>
> > 
> > so the schema gets checked for errors.
> > 
> > in my case the error was that foreign key definitions have to be after
> > the column definitions in the table element.
> > 
> > bye
> > fabian
> > 
> > On Thu, 2002-01-24 at 22:47, Fabian Moerchen wrote:
> > > i had a default method of native for the database tag all the time.
> > > still i tried many different combinations of defaultIdMethod and
> > > idMethod now but all produced the same, correct (?) SQL for the
> > > relation:
> > >
> > > CREATE TABLE ARTIST_HAS_WEBSITE
> > > (
> > >     ARTIST_ID INTEGER NOT NULL,
> > >     WEBSITE_ID INTEGER NOT NULL,
> > >     PRIMARY KEY(ARTIST_ID,WEBSITE_ID),
> > >     FOREIGN KEY (ARTIST_ID) REFERENCES ARTIST (ID),
> > >     FOREIGN KEY (WEBSITE_ID) REFERENCES WEBSITE (ID)
> > > );
> > >
> > > and e.g. for the websites
> > >
> > > CREATE TABLE WEBSITE
> > > (
> > >     ID INTEGER NOT NULL AUTO_INCREMENT,
> > >     NAME VARCHAR (100) NOT NULL,
> > >     URL VARCHAR (200) NOT NULL,
> > >     PRIMARY KEY(ID)
> > > );
> > >
> > > still artist1.getPrimaryKey() give me always null after saving and the
> > > other problems described also persist.
> > >
> > > bye
> > > fabian
> > >
> > > On Thu, 2002-01-24 at 17:49, John McNally wrote:
> > > > I notice you are not specifying an idmethod attribute on your tables,
> > > > are you specifying a default.  I suspect not as then you would probably
> > > > have the attribute on your ARTIST_HAS_WEBSITE table.
> > > >
> > > > Use idmethod="native" or idmethod="autoincrement", if native does not
> > > > work, on tables that have generated pk's.  And then use idmethod="none"
> > > > on tables such as ARTIST_HAS_WEBSITE.
> > > >
> > > > john mcnally
> > > >
> > > > Fabian Moerchen wrote:
> > > > >
> > > > > here's (part of) my schema. did i do something wrong?
> > > > > could very well be since it's my first. ;)
> > > > >
> > > > >   <table name="GENRE">
> > > > >     <column name="ID" type="INTEGER" required="true"
> > > > >      autoIncrement="true" primaryKey="true"/>
> > > > >     <column name="NAME" type="VARCHAR" size="50" required="true"/>
> > > > >     <unique>
> > > > >       <unique-column name="NAME"/>
> > > > >     </unique>
> > > > >   </table>
> > > > >   <table name="ARTIST">
> > > > >     <column name="ID" type="INTEGER" required="true"
> > > > >      autoIncrement="true" primaryKey="true"/>
> > > > >     <column name="NAME" type="VARCHAR" size="100" required="true"/>
> > > > >     <column name="PATTERN" type="VARCHAR" size="255"/>
> > > > >     <column name="SORTNAME" type="VARCHAR" size="255"/>
> > > > >     <column name="GENRE_ID" type="INTEGER"/>
> > > > >     <foreign-key foreignTable="GENRE">
> > > > >       <reference local="GENRE_ID" foreign="ID"/>
> > > > >     </foreign-key>
> > > > >   </table>
> > > > >   <table name="WEBSITE">
> > > > >     <column name="ID" type="INTEGER" required="true"
> > > > >      autoIncrement="true" primaryKey="true"/>
> > > > >     <column name="NAME" type="VARCHAR" size="100" required="true"/>
> > > > >     <column name="URL" type="VARCHAR" size="200" required="true"/>
> > > > >   </table>
> > > > >   <table name="ARTIST_HAS_WEBSITE">
> > > > >     <column name="ARTIST_ID" type="INTEGER" required="true"
> > > > >      primaryKey="true"/>
> > > > >     <foreign-key foreignTable="ARTIST">
> > > > >       <reference local="ARTIST_ID" foreign="ID"/>
> > > > >     </foreign-key>
> > > > >     <column name="WEBSITE_ID" type="INTEGER" required="true"
> > > > >      primaryKey="true"/>
> > > > >     <foreign-key foreignTable="WEBSITE">
> > > > >       <reference local="WEBSITE_ID" foreign="ID"/>
> > > > >     </foreign-key>
> > > > >   </table>
> > > > >
> > > > > bye
> > > > > fabian
> > > > >
> > > > > On Thu, 2002-01-24 at 07:28, John McNally wrote:
> > > > > > The first example should work.  You might want to show your schema.xml,
> > > > > > to give others some idea what might be wrong.  artist1.getPrimaryKey()
> > > > > > should give the id assigned after saving the object.  It should not be
> > > > > > null.  If it is something is wrong with your xml.
> > > > > >
> > > > > > john mcnally
> > > > > >
> > > > > > >
> > > > > > > this doesn't work:
> > > > > > >
> > > > > > > Artist artist1 = new Artist();
> > > > > > > artist1.setName("Primus");
> > > > > > > artist1.save();
> > > > > > >
> > > > > > > Website website1 = new Website();
> > > > > > > website1.setName("Primus Online");
> > > > > > > website1.setUrl("http://www.primussucks.com";);
> > > > > > > website1.save();
> > > > > > >
> > > > > > > ArtistHasWebsite link = new ArtistHasWebsite();
> > > > > > > link.setArtist(artist1);
> > > > > > > link.setWebsite(website1);
> > > > > > > link.save(); //Column 'ARTIST_ID' cannot be null
> > > > > > >
> > > > > > > this does work:
> > > > > > >
> > > > > > > Artist artist1 = new Artist();
> > > > > > > artist1.setName("Primus");
> > > > > > > artist1.save();
> > > > > > >
> > > > > > > Website website1 = new Website();
> > > > > > > website1.setName("Primus Online");
> > > > > > > website1.setUrl("http://www.primussucks.com";);
> > > > > > > website1.save();
> > > > > > >
> > > > > > > Artist artist2 = ArtistFactory.findByName(artist1.getName());
> > > > > > > Website website2 = WebsiteFactory.findByUrl(website1.getUrl());
> > > > > > >
> > > > > > > ArtistHasWebsite link = new ArtistHasWebsite();
> > > > > > > link.setArtist(artist2);
> > > > > > > link.setWebsite(website2);
> > > > > > > link.save();
> > > > > > >
> > > > > > > tried defaultIdMethod native and idBroker by now.
> > > > > > >
> > > > > > > bye
> > > > > > > fabian
> > > > > > >
> > > > > > > --
> > > > > > > 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]>
> > > > > >
> > > > > >
> > > > >
> > > > > --
> > > > > 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]>
> > > >
> > > >
> > >
> > >
> > > --
> > > 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]>
> 
> --
> 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