Hi Bernd,

First of all, you don't need to do the nextID / setID explicitly. 
addRecord() does that for you, so when you do this:

>Area r = (Area)t.addRecord();

r already has the next id, from the maxIDs table.  (For those who are 
interested: grabbing the next id always occurs in a separate 
transaction and commits immediately, thus guaranteeing that you never 
get duplicate IDs.  This does mean, however, that if you run 
addRecord() but don't save() it, the id doesn't get reused).

Even so, I'm not sure why you're getting a NullPointerException... 
can you send the full stack trace?  (Be sure to do "setenv 
JAVA_COMPILER none" or the equivalent on your system, otherwise you 
won't get line numbers in the trace).

Thanks,

-David


>I started with Town a few days ago but couldn't get any record beeing
>saved to my database until now. If you have a look at the following
>code, everithing works fine until the r.save()-command. This causes a
>NullPointerException. Is there any special thing to take care of when
>saving records?
>
>Note, that the connection to the database and to the tables are all
>right, the permissions are, too.
>
> Table t = csdb.AreaTable();
> Table et = csdb.EmployeesTable();
>
>Area r = (Area)t.addRecord();
>
>Employees e = (Employees)et.selectOne("name = 'Richter'");
>
>r.setFachgebiet("POM"); // Fachgebiet
>int dummy = csdb.nextID("Area");
>r.setId(new Integer(dummy)); // neue ID
>r.setEmployees(e); // neue Referenz auf Sachbearbeiter
>
> r.save();  // -> causes NullPointerException !!
>
>Thanks
>Bernd
>
>--
>------------------------------------------------
>
>Mit freundlichen Gr��en
>
>Bernd Adamowicz
>Softwareentwicklung
>
>------------------------------------------------
>CAD Praxis GmbH
>Rudolfstra�e 27a
>88214 Ravensburg
>Tel.: +49-751-366 16-0
>Fax.: +49-751-366 16-51
>Hotline: 01803 223772 oder [EMAIL PROTECTED]
>mailto:[EMAIL PROTECTED]
>mailto:[EMAIL PROTECTED]
>http://www.cad-praxis.de
>------------------------------------------------
>
>
>
>
>
>------------------------------------------------------------
>To subscribe:        [EMAIL PROTECTED]
>To unsubscribe:      [EMAIL PROTECTED]
>Problems?:           [EMAIL PROTECTED]


________________________________________________________________________
David Soergel               .oooO  Oooo.       "Music and Living----"
1215 2nd Avenue             (   )  (   )    "The same thing," said Pooh.
San Francisco, CA  94122     \ (    ) /           [EMAIL PROTECTED]
(650) 303-5324                \_)  (_/          http://www.lorax.org
________________________________________________________________________



------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Problems?:           [EMAIL PROTECTED]

Reply via email to