You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by John McNally <jm...@collab.net> on 2001/10/18 22:00:45 UTC

Re: Torque and required columns

If you are updating an object which already is stored in the db.  Use
EntryPeer.retrieveByPK(id) to get the object, change the appropriate
fields, then save() it.  If you are trying to instantiate a new Entry
and force it to be representative of the stored version, you need to
supply the new Entry with the relevant info.

john mcnally

Skip Walker wrote:
> 
> 
> Question:
> If I define a column as required="false", when I use a Torque Object,
> should the value of this column be set to null, if I don't set the value
> of the column in the Torque object before I call save?
> 
> For instance, suppose I have a non-nullable column, dateCreated, which I
> only want to set when I first create the row in the database.  (on an
> insert ).
> 
> I wrote code similar to the following in order to do this, (Entry is an
> extension of BaseObject)
> 
> Entry e = new Entry();
> 
> ...
> 
> if (e.isNew() )
>     e.setDateCreated(curTime);
> 
> ...
> 
> e.save();
> 
> 
> This works fine when the entry is new, and an insert is performed.
> However, if the entry is not new, then I get generated from my db2
> database telling me I'm attempting to insert a null into a column
> defined as NOT NULL.
> 
> Now, if I change the dateCreated column to be nullable, then the code
> works fine with out exceptions.  However, when an entry is not new, and
> an updated is performed, the dateCreated value is replaced with a null.
> Is this expected behavior from torque?  I thought that if a column was
> defined as required="false" in the schema, then on an insert or update,
> torque would be smart, and not attempt to insert or update any field
> whose value had not been set in the Object peer.
> 
> Any suggestions would be greatly appreciated.
> 
> Thanks,
> Skip
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: Torque and required columns

Posted by Jason Kary <jk...@cisco.com>.
Hi,

Attached is the start of a user manual for Torque.  I have a lot of
questions.  If anyone would like to contribute, all my questions are
prefaced with 'XXX'.  

The format is not pretty at the moment as I am concentrating on
content.  If there are any major sections that seem to be missing can
you please let me know.  

Take Care
Jason


On Fri, 2001-10-19 at 10:21, Jason Kary wrote:
> Hi,
> 
> Has anyonen started on a user manual for Torque?  If not I would like to
> help out by starting one.  
> 
> Is there any docs that I can research reguarding how to write xdocs for
> torque?
> 
> Is it useful to start a user manual for Torque at this point?
> 
> Take Care
> Jason Kary
> 
> 
> On Thu, 2001-10-18 at 16:00, John McNally wrote:
> > If you are updating an object which already is stored in the db.  Use
> > EntryPeer.retrieveByPK(id) to get the object, change the appropriate
> > fields, then save() it.  If you are trying to instantiate a new Entry
> > and force it to be representative of the stored version, you need to
> > supply the new Entry with the relevant info.
> > 
> > john mcnally
> > 
> > Skip Walker wrote:
> > > 
> > > 
> > > Question:
> > > If I define a column as required="false", when I use a Torque Object,
> > > should the value of this column be set to null, if I don't set the value
> > > of the column in the Torque object before I call save?
> > > 
> > > For instance, suppose I have a non-nullable column, dateCreated, which I
> > > only want to set when I first create the row in the database.  (on an
> > > insert ).
> > > 
> > > I wrote code similar to the following in order to do this, (Entry is an
> > > extension of BaseObject)
> > > 
> > > Entry e = new Entry();
> > > 
> > > ...
> > > 
> > > if (e.isNew() )
> > >     e.setDateCreated(curTime);
> > > 
> > > ...
> > > 
> > > e.save();
> > > 
> > > 
> > > This works fine when the entry is new, and an insert is performed.
> > > However, if the entry is not new, then I get generated from my db2
> > > database telling me I'm attempting to insert a null into a column
> > > defined as NOT NULL.
> > > 
> > > Now, if I change the dateCreated column to be nullable, then the code
> > > works fine with out exceptions.  However, when an entry is not new, and
> > > an updated is performed, the dateCreated value is replaced with a null.
> > > Is this expected behavior from torque?  I thought that if a column was
> > > defined as required="false" in the schema, then on an insert or update,
> > > torque would be smart, and not attempt to insert or update any field
> > > whose value had not been set in the Object peer.
> > > 
> > > Any suggestions would be greatly appreciated.
> > > 
> > > Thanks,
> > > Skip
> > > 
> > > 
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: turbine-user-help@jakarta.apache.org
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: turbine-user-help@jakarta.apache.org
> > 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
> 



Re: Torque and required columns

Posted by Martin Poeschl <mp...@marmot.at>.
Jason Kary wrote:

> Hi,
>
> Has anyonen started on a user manual for Torque?  If not I would like to
> help out by starting one.

turbine-2 docs include some torque related docs (torque-howto, torque schema
ref, ..)
currently there is no documentation for the sepearted torque package :-(

documentation is always welcome ... ;-)

> Is there any docs that I can research reguarding how to write xdocs for
> torque?

http://jakarta.apache.org/site/jakarta-site2.html
http://jakarta.apache.org/site/jakarta-site-tags.html


> Is it useful to start a user manual for Torque at this point?

i'm sure there will be changes before the next release, but if we have some docs
we can update them ....
so if you find the time to write some docs, just send your stuff to the
turbine-dev list and we will add it

martin


>
>
> Take Care
> Jason Kary
>
> On Thu, 2001-10-18 at 16:00, John McNally wrote:
> > If you are updating an object which already is stored in the db.  Use
> > EntryPeer.retrieveByPK(id) to get the object, change the appropriate
> > fields, then save() it.  If you are trying to instantiate a new Entry
> > and force it to be representative of the stored version, you need to
> > supply the new Entry with the relevant info.
> >
> > john mcnally
> >
> > Skip Walker wrote:
> > >
> > >
> > > Question:
> > > If I define a column as required="false", when I use a Torque Object,
> > > should the value of this column be set to null, if I don't set the value
> > > of the column in the Torque object before I call save?
> > >
> > > For instance, suppose I have a non-nullable column, dateCreated, which I
> > > only want to set when I first create the row in the database.  (on an
> > > insert ).
> > >
> > > I wrote code similar to the following in order to do this, (Entry is an
> > > extension of BaseObject)
> > >
> > > Entry e = new Entry();
> > >
> > > ...
> > >
> > > if (e.isNew() )
> > >     e.setDateCreated(curTime);
> > >
> > > ...
> > >
> > > e.save();
> > >
> > >
> > > This works fine when the entry is new, and an insert is performed.
> > > However, if the entry is not new, then I get generated from my db2
> > > database telling me I'm attempting to insert a null into a column
> > > defined as NOT NULL.
> > >
> > > Now, if I change the dateCreated column to be nullable, then the code
> > > works fine with out exceptions.  However, when an entry is not new, and
> > > an updated is performed, the dateCreated value is replaced with a null.
> > > Is this expected behavior from torque?  I thought that if a column was
> > > defined as required="false" in the schema, then on an insert or update,
> > > torque would be smart, and not attempt to insert or update any field
> > > whose value had not been set in the Object peer.
> > >
> > > Any suggestions would be greatly appreciated.
> > >
> > > Thanks,
> > > Skip
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: turbine-user-help@jakarta.apache.org
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: turbine-user-help@jakarta.apache.org
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: Torque and required columns

Posted by Jason Kary <jk...@cisco.com>.
Hi,

Has anyonen started on a user manual for Torque?  If not I would like to
help out by starting one.  

Is there any docs that I can research reguarding how to write xdocs for
torque?

Is it useful to start a user manual for Torque at this point?

Take Care
Jason Kary


On Thu, 2001-10-18 at 16:00, John McNally wrote:
> If you are updating an object which already is stored in the db.  Use
> EntryPeer.retrieveByPK(id) to get the object, change the appropriate
> fields, then save() it.  If you are trying to instantiate a new Entry
> and force it to be representative of the stored version, you need to
> supply the new Entry with the relevant info.
> 
> john mcnally
> 
> Skip Walker wrote:
> > 
> > 
> > Question:
> > If I define a column as required="false", when I use a Torque Object,
> > should the value of this column be set to null, if I don't set the value
> > of the column in the Torque object before I call save?
> > 
> > For instance, suppose I have a non-nullable column, dateCreated, which I
> > only want to set when I first create the row in the database.  (on an
> > insert ).
> > 
> > I wrote code similar to the following in order to do this, (Entry is an
> > extension of BaseObject)
> > 
> > Entry e = new Entry();
> > 
> > ...
> > 
> > if (e.isNew() )
> >     e.setDateCreated(curTime);
> > 
> > ...
> > 
> > e.save();
> > 
> > 
> > This works fine when the entry is new, and an insert is performed.
> > However, if the entry is not new, then I get generated from my db2
> > database telling me I'm attempting to insert a null into a column
> > defined as NOT NULL.
> > 
> > Now, if I change the dateCreated column to be nullable, then the code
> > works fine with out exceptions.  However, when an entry is not new, and
> > an updated is performed, the dateCreated value is replaced with a null.
> > Is this expected behavior from torque?  I thought that if a column was
> > defined as required="false" in the schema, then on an insert or update,
> > torque would be smart, and not attempt to insert or update any field
> > whose value had not been set in the Object peer.
> > 
> > Any suggestions would be greatly appreciated.
> > 
> > Thanks,
> > Skip
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: turbine-user-help@jakarta.apache.org
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org