You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by Gary Shea <sh...@gtsdesign.com> on 2003/10/29 06:50:18 UTC

update difficulties

This is probably user error, but I'm having trouble with doUpdate(*).
I have dug through the code and searched the archives to no avail.  I'm
going to keep going in the code, but if anyone can explain this, please do!

I have used Torque to generate a schema and classes.  I do a simple
lookup:
        
        Criteria criteria = new Criteria("summary");
        criteria.addIn(TransSummaryPeer.XID, xids);
        Collection records = TransSummaryPeer.doSelect(criteria);

and then modify a record returned in the collection using Apache BeanUtils:

        PropertyUtils.setProperty(
            record, propName,
            PropertyUtils.getProperty(vo, propName));

and print out the Torque object to insure that the property
has in fact changed: it has.  Check if 'modified' is true: it is.
Attempt to save the changes:
       
        record.save("summary");

Look in the mysql log, and NOTHING HAPPENED!  Nor is an exception thrown,
unless it's being swallowed somewhere in Torque.  I am completely
baffled.  I have yet to find a path through the code that can have no
effect...

Interestingly, if I create a TransSummary object 'record' with an xid
(primary key) for which there is as yet no record in the database,
so that 'new' is true:

    record.save("summary");

works fine, storing the object into a database record.

Clues?

Thanks,

        Gary

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


Re: update difficulties

Posted by Gary Shea <sh...@gtsdesign.com>.
I've found some indication of what's going on, not sure if it's a bug or
not.  The key issue is that I've got multipe databases configured and
am using a non-default database.

Calling save(dbName) is converted into save(connection), and right there
the database name is lost.  The call chain builds a criteria for update
and one for select, and the select criteria's db name is explicitly set
to the default from the Base[MyClassNameHere]Peer.  Eventually the chain
reaches BasePeer.doUpdate(selectCriteria, updateValues, connection)
where the database information is pulled out of the database named in
select criteria.  So the connection is to the right database, but the
database metadata will be for the wrong database.  That's my
interpretation anyway.

Should I file a bug report or come up with a patch for this,
or am I missing something?  Also need to go back and see how it can
possibly work fine for doInsert() but not doUpdate()!

I have been unable to get a direct call to the BasePeer.doUpdate(3 args)
method working, keep getting a NPE on the following line:
    ColumnMap[] columnMaps = tempDbMap.getTable(tab).getColumns();

Now that I know why save() doesn't work, I'll start working with
BasePeer.doUpdate(3args) again.

Regards,

        Gary

[2003-10-28 22:50 -0700] Gary Shea (shea@gtsdesign.com) wrote:
> This is probably user error, but I'm having trouble with doUpdate(*).
> I have dug through the code and searched the archives to no avail.  I'm
> going to keep going in the code, but if anyone can explain this, please do!
> 
> I have used Torque to generate a schema and classes.  I do a simple
> lookup:
>         
>         Criteria criteria = new Criteria("summary");
>         criteria.addIn(TransSummaryPeer.XID, xids);
>         Collection records = TransSummaryPeer.doSelect(criteria);
> 
> and then modify a record returned in the collection using Apache BeanUtils:
> 
>         PropertyUtils.setProperty(
>             record, propName,
>             PropertyUtils.getProperty(vo, propName));
> 
> and print out the Torque object to insure that the property
> has in fact changed: it has.  Check if 'modified' is true: it is.
> Attempt to save the changes:
>        
>         record.save("summary");
> 
> Look in the mysql log, and NOTHING HAPPENED!  Nor is an exception thrown,
> unless it's being swallowed somewhere in Torque.  I am completely
> baffled.  I have yet to find a path through the code that can have no
> effect...
> 
> Interestingly, if I create a TransSummary object 'record' with an xid
> (primary key) for which there is as yet no record in the database,
> so that 'new' is true:
> 
>     record.save("summary");
> 
> works fine, storing the object into a database record.
> 
> Clues?
> 
> Thanks,
> 
>         Gary
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
> 
> 
> 

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


RE: update difficulties

Posted by Scott Shorter <ss...@orionsec.com>.
Gary,

Oops.  I was assuming that "summary" was a field and didn't do my
research, so I guessed that it needed a constant field name from the
*Peer class.  Like I said, Torque newbie here...
-
Scott

> -----Original Message-----
> From: Gary Shea [mailto:shea@gtsdesign.com] 
> Sent: Wednesday, October 29, 2003 11:45 AM
> To: Apache Torque Users List
> Subject: RE: update difficulties
> 
> 
> Hi Scott --
> 
> Thanks for jumping in!
> 
> There are three different save() signatures: no args, a 
> Connection, and a database name.  The one I've used is the 
> database name.  I don't see one that takes a field name... 
> what did you have in mind?
> 
> Regards,
> 
>         Gary
> 
> [2003-10-29 08:28 -0500] Scott Shorter (sshorter@orionsec.com) wrote:
> 
> > I know I'm just a newb here myself, but have you tried
> > 
> > 	record.save(TransSummaryPeer.SUMMARY);
> > --
> > Scott
> > 
> > 
> > > -----Original Message-----
> > > From: Gary Shea [mailto:shea@gtsdesign.com]
> > > Sent: Wednesday, October 29, 2003 12:50 AM
> > > To: torque-user@db.apache.org
> > > Subject: update difficulties
> > > 
> > > 
> > > This is probably user error, but I'm having trouble with
> > > doUpdate(*). I have dug through the code and searched the 
> > > archives to no avail.  I'm going to keep going in the code, 
> > > but if anyone can explain this, please do!
> > > 
> > > I have used Torque to generate a schema and classes.  I 
> do a simple
> > > lookup:
> > >         
> > >         Criteria criteria = new Criteria("summary");
> > >         criteria.addIn(TransSummaryPeer.XID, xids);
> > >         Collection records = TransSummaryPeer.doSelect(criteria);
> > > 
> > > and then modify a record returned in the collection using
> > > Apache BeanUtils:
> > > 
> > >         PropertyUtils.setProperty(
> > >             record, propName,
> > >             PropertyUtils.getProperty(vo, propName));
> > > 
> > > and print out the Torque object to insure that the 
> property has in 
> > > fact changed: it has.  Check if 'modified' is true: it 
> is. Attempt 
> > > to save the changes:
> > >        
> > >         record.save("summary");
> > > 
> > > Look in the mysql log, and NOTHING HAPPENED!  Nor is an
> > > exception thrown, unless it's being swallowed somewhere in 
> > > Torque.  I am completely baffled.  I have yet to find a path 
> > > through the code that can have no effect...
> > > 
> > > Interestingly, if I create a TransSummary object 'record'
> > > with an xid (primary key) for which there is as yet no record 
> > > in the database, so that 'new' is true:
> > > 
> > >     record.save("summary");
> > > 
> > > works fine, storing the object into a database record.
> > > 
> > > Clues?
> > > 
> > > Thanks,
> > > 
> > >         Gary
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
> 


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


RE: update difficulties

Posted by Gary Shea <sh...@gtsdesign.com>.
Hi Scott --

Thanks for jumping in!

There are three different save() signatures: no args, a Connection,
and a database name.  The one I've used is the database name.  I don't
see one that takes a field name... what did you have in mind?

Regards,

        Gary

[2003-10-29 08:28 -0500] Scott Shorter (sshorter@orionsec.com) wrote:

> I know I'm just a newb here myself, but have you tried
> 
> 	record.save(TransSummaryPeer.SUMMARY);
> --
> Scott
> 
> 
> > -----Original Message-----
> > From: Gary Shea [mailto:shea@gtsdesign.com] 
> > Sent: Wednesday, October 29, 2003 12:50 AM
> > To: torque-user@db.apache.org
> > Subject: update difficulties
> > 
> > 
> > This is probably user error, but I'm having trouble with 
> > doUpdate(*). I have dug through the code and searched the 
> > archives to no avail.  I'm going to keep going in the code, 
> > but if anyone can explain this, please do!
> > 
> > I have used Torque to generate a schema and classes.  I do a simple
> > lookup:
> >         
> >         Criteria criteria = new Criteria("summary");
> >         criteria.addIn(TransSummaryPeer.XID, xids);
> >         Collection records = TransSummaryPeer.doSelect(criteria);
> > 
> > and then modify a record returned in the collection using 
> > Apache BeanUtils:
> > 
> >         PropertyUtils.setProperty(
> >             record, propName,
> >             PropertyUtils.getProperty(vo, propName));
> > 
> > and print out the Torque object to insure that the property
> > has in fact changed: it has.  Check if 'modified' is true: it 
> > is. Attempt to save the changes:
> >        
> >         record.save("summary");
> > 
> > Look in the mysql log, and NOTHING HAPPENED!  Nor is an 
> > exception thrown, unless it's being swallowed somewhere in 
> > Torque.  I am completely baffled.  I have yet to find a path 
> > through the code that can have no effect...
> > 
> > Interestingly, if I create a TransSummary object 'record' 
> > with an xid (primary key) for which there is as yet no record 
> > in the database, so that 'new' is true:
> > 
> >     record.save("summary");
> > 
> > works fine, storing the object into a database record.
> > 
> > Clues?
> > 
> > Thanks,
> > 
> >         Gary

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


RE: update difficulties

Posted by Scott Shorter <ss...@orionsec.com>.
I know I'm just a newb here myself, but have you tried

	record.save(TransSummaryPeer.SUMMARY);
--
Scott


> -----Original Message-----
> From: Gary Shea [mailto:shea@gtsdesign.com] 
> Sent: Wednesday, October 29, 2003 12:50 AM
> To: torque-user@db.apache.org
> Subject: update difficulties
> 
> 
> This is probably user error, but I'm having trouble with 
> doUpdate(*). I have dug through the code and searched the 
> archives to no avail.  I'm going to keep going in the code, 
> but if anyone can explain this, please do!
> 
> I have used Torque to generate a schema and classes.  I do a simple
> lookup:
>         
>         Criteria criteria = new Criteria("summary");
>         criteria.addIn(TransSummaryPeer.XID, xids);
>         Collection records = TransSummaryPeer.doSelect(criteria);
> 
> and then modify a record returned in the collection using 
> Apache BeanUtils:
> 
>         PropertyUtils.setProperty(
>             record, propName,
>             PropertyUtils.getProperty(vo, propName));
> 
> and print out the Torque object to insure that the property
> has in fact changed: it has.  Check if 'modified' is true: it 
> is. Attempt to save the changes:
>        
>         record.save("summary");
> 
> Look in the mysql log, and NOTHING HAPPENED!  Nor is an 
> exception thrown, unless it's being swallowed somewhere in 
> Torque.  I am completely baffled.  I have yet to find a path 
> through the code that can have no effect...
> 
> Interestingly, if I create a TransSummary object 'record' 
> with an xid (primary key) for which there is as yet no record 
> in the database, so that 'new' is true:
> 
>     record.save("summary");
> 
> works fine, storing the object into a database record.
> 
> Clues?
> 
> Thanks,
> 
>         Gary
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
> 


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