Stuart

Its the same concept, just convert the int to an Integer and pass that
to retrieveByPK().


 
On Sat, 2003-03-08 at 15:04, Stuart Townhill wrote:
> Bill,
> 
> I have managed to fix it with the help of Akmal. I only got it to work
> by using a "primitive" defaultObject type for the database. For future
> reference how would you go about it for an "object" type?
> 
> Regards,
> 
> Stuart Townhill.
> 
> 
> -----Original Message-----
> From: Stuart Townhill [mailto:[EMAIL PROTECTED] 
> Sent: 08 March 2003 19:29
> To: 'Turbine Users List'
> Subject: RE: Intake Part 2
> 
> Bill,
> 
> Thanks for the reply my database was created using the following:
> 
> <database name="covert" defaultIdMethod="idbroker"
> defaultJavaType="object">
> 
> I have looked at the BaseCustomerPeer class and it has the following
> methods:
> 
> ---BaseCustomerPeer---
> 
> public static Customer retrieveByPK(Integer pk)
>     throws TorqueException
> {
>     return retrieveByPK(SimpleKey.keyFor(pk));
> }
> 
> public static Customer retrieveByPK(ObjectKey pk)
>     throws TorqueException
> {
>     Connection db = null;
>     Customer retVal = null;
>     try
>     {
>         db = Torque.getConnection(DATABASE_NAME);
>         retVal = retrieveByPK(pk, db);
>     }
>     finally
>     {
>         Torque.closeConnection(db);
>     }
>     return(retVal);
> }
> 
> public static Customer retrieveByPK(ObjectKey pk, Connection con)
>     throws TorqueException
> {
>     Criteria criteria = buildCriteria(pk);
>     List v = doSelect(criteria, con);
>     if (v.size() != 1)
>     {
>         throw new TorqueException("Failed to select one and only one
> row.");
>     }
>     else
>     {
>         return (Customer)v.get(0);
>     }
> }
> 
> Not sure which version of Intake I am using I presume it is 2.2 as I am
> using the intake that was bundled with the TDK2.2. Your help is much
> appreciated.
> 
> Regards,
> 
> Stuart Townhill.
> 
> 
> -----Original Message-----
> From: Bill [mailto:[EMAIL PROTECTED] 
> Sent: 08 March 2003 18:16
> To: Turbine Users List
> Subject: RE: Intake Part 2
> 
> Stuart
> 
> I dont know what version of intake you are currently using, but I think
> the problem is you are passing parameters of the wrong type.
> 
> Look up the method in your BaseCustomerPeer class to determine how to
> pass it.  In 2.1 it you would have passed an ObjectKey, in 2.2 it
> depends on what type the primary key is in the database and whether you
> built your classes with defaultObjects of "primitive" or "object", so i
> cant be more specific.
> 
> 
> 
> 
> On Sat, 2003-03-08 at 12:42, Stuart Townhill wrote:
> > Akmal,
> > 
> > Thanks for the response I get the following error when implementing "
> >
> customer=(Customer)CustomerPeer.retrieveByPk(data.getParameters().getInt
> > ("cu
> > stomerentry"));" within my doUpdate method, I do have the following
> > within my class:
> > 
> > import soundideas.covert.om.Customer;
> > import soundideas.covert.om.CustomerPeer;
> > 
> > 
> > compile:
> >     [javac] Compiling 52 source files to
> > C:\turbine\webapps\covert\WEB-INF\classes
> >     [javac]
> >
> C:\turbine\webapps\covert\WEB-INF\src\java\soundideas\covert\modules\act
> > ions\doInsertCustomer.java:86: cannot resolve symbol
> >     [javac] symbol  : method retrieveByPk (int)
> >     [javac] location: class soundideas.covert.om.CustomerPeer
> >     [javac] Customer customer =
> >
> (Customer)CustomerPeer.retrieveByPk(data.getParameters().getInt("custome
> > rentry"));
> >     [javac]               ^
> >     [javac] 1 error
> > 
> > BUILD FAILED
> > 
> > I haven't really seen this a lot within the mailing lists, I have seen
> a
> > lot to do with queryKeys what is the correct way to be doing this?
> > 
> > Many thanks, Regards,
> > 
> > Stuart.
> > 
> > 
> > 
> > -----Original Message-----
> > From: Akmal Sarhan [mailto:[EMAIL PROTECTED] 
> > Sent: 08 March 2003 16:39
> > To: Turbine Users List
> > Subject: Re: Intake Part 2
> > 
> > ...validation stuff...
> > Customer
> >
> customer=(Customer)CustomerPeer.retrieveByPk(data.getParameters().getInt
> > ("cu
> > stomerentry"));
> > group.setProperties(customer);
> > customer.save();
> > 
> > regards
> > Akmal
> > ----- Original Message -----
> > From: "Stuart Townhill" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Saturday, March 08, 2003 4:15 PM
> > Subject: Intake Part 2
> > 
> > 
> > > To anyone who can help,
> > >
> > > Last weekend I managed to successfully use intake to validate and
> > empty
> > > form i.e. a new record in the database. Now I have managed to use
> > > criteria to select a certain record from the database and insert it
> > into
> > > context and then map the values to the form (This is so I can edit a
> > > record in the database and still use intake to validate). Where I am
> > > having problems is with the Update I have copied and my method
> below.
> > I
> > > noticed in the html that the $intake.declareGroups() method adds a
> > > hidden field with the value being the primary key of the record
> being
> > > updated so I used that for the "intake.get" method. Everything seems
> > to
> > > execute smoothly but no update goes through to the database.
> > >
> > > public void doUpdate(RunData data, Context context)
> > >     throws Exception
> > > {
> > >     IntakeTool intake = (IntakeTool)context.get("intake");
> > >     Group group = intake.get("Customerentry",
> > > data.getParameters().getString("customerentry"));
> > >     if (group.isAllValid())
> > >     {
> > >         Customer customer = new Customer();
> > >         group.setProperties(customer);
> > >         customer.setModified(true);
> > >         customer.setNew(false);
> > >         customer.save();
> > >
> > >
> >
> data.setScreenTemplate(data.getParameters().getString("nextTemplate"));
> > >     }
> > > }
> > >
> > > Any help is much appreciated.
> > >
> > > Regards,
> > >
> > > Stuart Townhill.
> > >
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > 
> > 
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to