db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Rasmussen <jrasmus...@lnxi.com>
Subject Re: Printing SQL
Date Thu, 04 Dec 2003 23:03:54 GMT
In the Base"TABLE"Peer File created by torque You should have a method
doInsert(Object).

This builds a criteria from the Object.
Then calls doInsert(Criteria).
Ex.

    /** Method to do inserts */
    public static void doInsert(Node obj) throws TorqueException
    {
                doInsert(buildCriteria(obj));
                obj.setNew(false);
                obj.setModified(false);
    }


     /**
     * Method to do inserts
     */
    public static ObjectKey doInsert(Criteria criteria)
        throws TorqueException{
        return BaseNodePeer
            .doInsert(criteria, (Connection) null);
    }


You should be able to add a println on the second method as follows:

/**
     * Method to do inserts
     */
    public static ObjectKey doInsert(Criteria criteria) throws
TorqueException{
        System.out.println(criteria.toString());
        return BaseNodePeer.doInsert(criteria, (Connection) null);
    }

I have not tried this so forgive me if it doesn't work.


Jeff Rasmussen


On Thu, 2003-12-04 at 15:52, Sonu Vijay wrote:
> Yeah, I am having problems with Inserts. And it the
> damn DB2400. Everything works perfectly when I tried
> on MySQL. But there also I Criteria prints only
> Selects, no Inserts get printed.
> 
> I don't understand when a Select is done
> Criteria.toString() prints a SELECT SQL and when an
> Insert is being done then also its give a SELECT only.
> 
> What's going on here.
> 
> 
> --- Scott Eade <seade@backstagetech.com.au> wrote:
> > This will log selects, but not inserts and updates.
> > 
> > Scott
> > 
> > -- 
> > Scott Eade
> > Backstage Technologies Pty. Ltd.
> > http://www.backstagetech.com.au
> > 
> > 
> > Tulsi Das wrote:
> > 
> > >or, better yet, you can setup Log4J to DEBUG level,
> > and all queries get
> > >printed out to wherever you've configured it.
> > >
> > >tulsi
> > >
> > >
> > > --- Jeff Rasmussen <jrasmussen@lnxi.com> escribi:
> > 
> > >  
> > >
> > >>This should work. I've been using it.
> > >>
> > >>Criteria crit = new Criteria();
> > >>....
> > >>....
> > >>....
> > >>System.out.println(crit.toString());
> > >>
> > >>Jeff Rasmussen
> > >>
> > >>On Thu, 2003-12-04 at 15:13, Sonu Vijay wrote:
> > >>    
> > >>
> > >>>Hi,
> > >>>Can we print the actual SQL that is made out of
> > the
> > >>>Criteria.
> > >>>My selects work but inserts don't, I need to see
> > the
> > >>>SQL as the following stack trace indicated syntax
> > >>>errors.
> > >>>
> > >>>Thanks
> > >>>
> > >>>Vijay
> > >>>      
> > >>>
> > 
> > 
> > 
> > 
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > torque-user-unsubscribe@db.apache.org
> > For additional commands, e-mail:
> > torque-user-help@db.apache.org
> > 
> 
> 
> __________________________________
> Do you Yahoo!?
> Free Pop-Up Blocker - Get it now
> http://companion.yahoo.com/
> 
> ---------------------------------------------------------------------
> 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


Mime
View raw message