Why not use
aBroker = (og_Broker) db.load( og_Broker.class, brokerNbr)
I guess if you do a query it has to run it through the db to see if any
identity fields match. I suppose it doesn't distinguish between an identity
field and other fields when doing a query.
Bert.
--- David Tam <[EMAIL PROTECTED]> wrote:
> sorry but i dont know y the msg is cut off.
> here is the problem again:
>
> the following is my mapping:
>
> /***********************************************/
> <class name="og_Broker" access="read-only" identity="brokerCde" >
> <description>just a testing mapping for trying out castor</description>
> <cache-type type="count-limited" capacity="30"/>
> <map-to table="OGT_BKR" />
> <field name="brokerCde" type="string" required="true">
> <sql name="BKR_CDE" type="varchar" />
> </field>
> </class>
> /***********************************************/
>
> and the following is my code:
>
> /***********************************************/
> public static og_Broker get(String brokerNbr) throws Exception{
>
> Database db;
> Query oql;
> QueryResults results;
> og_Broker aBroker = null;
>
> db = myJDO.instance().getDatabase();
>
> db.begin();
> oql = db.getOQLQuery( "SELECT p FROM og_Broker p WHERE brokerCde=$1" );
> oql.bind(brokerNbr);
>
> results = oql.execute();
>
> if ( results.hasMore() ) {
> aBroker = (og_Broker) results.next();
> } else {
> throw new Exception("user not found");
> } // end if
>
> db.commit();
> results.close();
> oql.close();
> db.close();
> return aBroker;
> } // end get
> /***********************************************/
> and here is my very simply test on caching:
>
> /***********************************************/
> public class myCastorTest{
>
> public static void main(String args[]){
>
> try{
> System.out.println(og_Broker.get(args[1]).toString());
> for (int i = 0; i < 100; i++){
> og_Broker aBkr = og_Broker.get(args[1]);
> }
> }catch(Exception e){
> e.printStackTrace();
> }
> }
>
> } // end myCastorTest
>
> /***********************************************/
>
> and it seems castor goes to the DB every time for the same copy which should
> be
> able to get from cache?
>
>
> regards,
>
> dave
>
>
> _______________________
> CONFIDENTIALITY NOTICE:
>
> This message, together with any attachment, is intended only for the use of
> the individual or entity to whom it is addressed and contains information
> that is privileged and confidential. If you are not the intended recipient,
> please be informed that any dissemination, distribution or reproduction of
> this message (including any attachment) is strictly prohibited. If you have
> received this message in error, please notify us immediately by return e-mail
> and delete the original message. Thank you.
>
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
> unsubscribe castor-dev
>
__________________________________________________
Do You Yahoo!?
Yahoo! Sports - live college hoops coverage
http://sports.yahoo.com/
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev