Thanks Low Heng Sin! I will try this out. ----- Original Message ----- From: "Low Heng Sin" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, August 22, 2001 8:08 PM Subject: Re: [castor-dev] inserting defaults from Oracle when using Castor > I don't think what u are trying to do is possible ( no readonly field > support at the moment ). Why not just set the default value in the class's > constructor instead ( i.e., in the constructor, created = new Date() )? > > Regards, > Low Heng Sin ( [EMAIL PROTECTED] ) > > -----Original Message----- > From: yahoo 1 [mailto:[EMAIL PROTECTED]] > Sent: Thursday, August 23, 2001 2:44 > To: [EMAIL PROTECTED] > Subject: [castor-dev] inserting defaults from Oracle when using Castor > > > I am using castor to connect to an Oracle database > version 8.1. I have a table which is described > below. > > CREATE TABLE site ( > siteid number(9) NOT NULL , > url varchar2 (100) NOT NULL , > description varchar2 (100) NULL , > created date DEFAULT SysDate NOT NULL , > updated date DEFAULT SysDate NOT NULL , > deleted date NULL , > constraint site_pk primary key (siteid)); > > > The mapping file has the following code related to > this table > > <map-to table="site" xml="site" /> > <field name="siteId" type="integer" > > <sql name="siteId" type="integer" /> > <xml name="siteId" node="attribute" /> > </field> > <field name="url" type="string" > > <sql name="url" type="varchar" /> > <xml name="url" node="element" /> > </field> > <field name="description" type="string" > > <sql name="description" type="varchar" /> > <xml name="description" node="element" /> > </field> > <field name="created" type="date"> > <sql name="created" type="date" /> > <xml name="created" node="element"/> > </field> > <!-- <field name="updated" type="date"> > <sql name="updated" type="date"/> > <xml name="updated" node="element"/> > </field> > <field name="deleted" type="date"> > <sql name="deleted" type="date"/> > <xml name="deleted" node="element"/> > </field>--> > </class> > > I would like to be able to add new sites to this table > via Castor without sending a value for the "created" > field as I want the database to insert the current > date time stamp. However, when I run the application > I get the following error: > > [utasklist] java.sql.SQLException: ORA-01400: cannot > insert NULL into ("UWH"."SITE"."CREATED") > [utasklist] ORA-06512: at line 1 > > I do want to keep the mapping element for the > "created" field as I need to retrieve this information > and display it. > > Note: The "updated" field would get its initail date > time stamp the same way as "created" when the record > is first created. After that a trigger would update > this field every time an update occurs. > > What can I do to so I do not need to send date time > values via Castor to the database? > > Thanks > - rw > > > > > __________________________________________________ > Do You Yahoo!? > Make international calls for as low as $.04/minute with Yahoo! Messenger > http://phonecard.yahoo.com/ > > ----------------------------------------------------------- > If you wish to unsubscribe from this mailing, send mail to > [EMAIL PROTECTED] with a subject of: > unsubscribe castor-dev > > ----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to [EMAIL PROTECTED] with a subject of: unsubscribe castor-dev
