If I am not mistaken, the use of LIKE operators on numeric columns is not part of the standard SQL92 implementation. Both Oracle and MySQL implement this as an extension. If it is a platform specific extension then it is probably not reasonable to expect OJB to explicitly support it.
just my $0.02 worth. Tim -----Original Message----- From: Charles Anthony [mailto:[EMAIL PROTECTED] Sent: Thursday, February 27, 2003 6:41 AM To: 'OJB Users List' Subject: RE: addLike and integer fields Hi, I have to say that I am not convinced that you can/should be doing a "Like" on an Integer field. I'm fairly certain that on many databases you can only do Like on a VARCHAR field. I'm not sure that it makes any logical sense to do Like on anything but a VARCHAR, let alone whether OJB should support it. Cheers, Charles. >-----Original Message----- >From: O'Reilly John [mailto:[EMAIL PROTECTED] >Sent: 27 February 2003 11:06 >To: 'OJB Users List' >Subject: RE: addLike and integer fields > > >A workaround for the problem mentioned below is to use addSql: > >crit.addSql("upper( INTERNAL_PRODUCT_ID) like '%" + new Integer( >theProductModel.getInternalProductID() ).toString() + "%'" ); > >Note that in this case you have to use the actual db column >name. Is this >the only solution? > >Rgds, >John > > >-----Original Message----- >From: O'Reilly John [mailto:[EMAIL PROTECTED] >Sent: 26 February 2003 15:22 >To: 'OJB Users List' >Subject: addLike and integer fields > > >Hi, > >Is there an issue in OJB with performing like queries with >integer fields. >I'm trying to use the following criteria: > >crit.addLike( "internalProductID", "%" + >Integer.toString(theProductModel.getInternalProductID()) + "%" ); > >Query query = new QueryByCriteria(ProductModel.class, crit, true); >Collection lListOfProducts = getBroker().getCollectionByQuery(query); > >The field descriptor is as follows: > ><field-descriptor name="internalProductID" column="INTERNAL_PRODUCT_ID" >jdbc-type="INTEGER" > primarykey="true" > autoincrement="true" > sequence-name="product_id_seq"/> > >When I run the code I above I get an exception (strack trace >shown below). >There isn't any issue when I run something like the following >sql directly: > >select * from products where internal_product_id like '%25%' > >Also, the above works fine for 'VARCHAR' fields. > >Thanks, >John > >java.lang.ClassCastException: java.lang.String at >oracle.jdbc.driver.OraclePreparedStatement.setObject(OraclePrep >aredStatement >.java:2021) at >oracle.jdbc.driver.OraclePreparedStatement.setObject(OraclePrep >aredStatement >.java:2102) at >com.p6spy.engine.spy.P6PreparedStatement.setObject(P6PreparedSt >atement.java: >282) at >org.apache.ojb.broker.platforms.PlatformDefaultImpl.setObjectFo >rStatement(Pl >atformDefaultImpl.java:229) at >org.apache.ojb.broker.platforms.PlatformOracleImpl.setObjectFor >Statement(Pla >tformOracleImpl.java:126) at >org.apache.ojb.broker.accesslayer.StatementManager.bindStatemen >tValue(Statem >entManager.java:258) at >org.apache.ojb.broker.accesslayer.StatementManager.bindStatemen >t(StatementMa >nager.java:297) at >org.apache.ojb.broker.accesslayer.StatementManager.bindSelectio >nCriteria(Sta >tementManager.java:490) at >org.apache.ojb.broker.accesslayer.StatementManager.bindStatemen >t(StatementMa >nager.java:451) at >org.apache.ojb.broker.accesslayer.JdbcAccessImpl.executeQuery(J >dbcAccessImpl >.java:258) at >org.apache.ojb.broker.accesslayer.RsIterator.<init>(RsIterator. >java:175) >at >org.apache.ojb.broker.singlevm.RsIteratorFactoryImpl.createRsIt >erator(RsIter >atorFactoryImpl.java:95) at >org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getRsItera >torFromQuery( >PersistenceBrokerImpl.java:2146) at >org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getIterato >rFromQuery(Pe >rsistenceBrokerImpl.java:1550) at >org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollect >ionByQuery(Pe >rsistenceBrokerImpl.java:1235) at >org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollect >ionByQuery(Pe >rsistenceBrokerImpl.java:1363) at >org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollect >ionByQuery(Pe >rsistenceBrokerImpl.java:1389) at >org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollect >ionByQuery(Pe >rsistenceBrokerImpl.java:1376) at >org.apache.ojb.broker.singlevm.DelegatingPersistenceBroker.getC >ollectionByQu >ery(DelegatingPersistenceBroker.java:294) at >ie.mcps.product.dao.ProductDAO.searchForProduct(ProductDAO.java:509) >*************************************************************** >********* >This e-mail and any files transmitted with it are confidential >and may be >privileged and are intended solely for the individual named/ >for the use of >the individual or entity to whom they are addressed.If you are not the >intended addressee, you should not disseminate, distribute or copy this >e-mail.Please notify the sender immediately if you have >received this e-mail >by mistake and delete this e-mail from your system.If you are not the >intended recipient, you are notified that reviewing, >disclosing, copying, >distributing or taking any action in reliance on the contents >of this e-mail >is strictly prohibited.Please note that any views or opinions >expressed in >this e-mail are solely those of the author and do not >necessarily represent >those of Traventec Limited.E-mail transmission cannot be >guaranteed to be >secure or error-free as information could be intercepted, >corrupted, lost, >destroyed, or arrive late or incomplete.Traventec Limited >therefore does not >accept liability for any errors or omissions in the contents of this >message, which arise as a result of e-mail transmission.The >recipient should >check this e-mail and any attachments for the presence of viruses.This >e-mail has been swept for computer viruses however Traventec >Limited accepts >no liability for any damage caused by any virus transmitted by >this e-mail. > >--------------------------------------------------------------------- >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] >*************************************************************** >********* >This e-mail and any files transmitted with it are confidential >and may be >privileged and are intended solely for the individual named/ >for the use of >the individual or entity to whom they are addressed.If you are not the >intended addressee, you should not disseminate, distribute or copy this >e-mail.Please notify the sender immediately if you have >received this e-mail >by mistake and delete this e-mail from your system.If you are not the >intended recipient, you are notified that reviewing, >disclosing, copying, >distributing or taking any action in reliance on the contents >of this e-mail >is strictly prohibited.Please note that any views or opinions >expressed in >this e-mail are solely those of the author and do not >necessarily represent >those of Traventec Limited.E-mail transmission cannot be >guaranteed to be >secure or error-free as information could be intercepted, >corrupted, lost, >destroyed, or arrive late or incomplete.Traventec Limited >therefore does not >accept liability for any errors or omissions in the contents of this >message, which arise as a result of e-mail transmission.The >recipient should >check this e-mail and any attachments for the presence of viruses.This >e-mail has been swept for computer viruses however Traventec >Limited accepts >no liability for any damage caused by any virus transmitted by >this e-mail. > >--------------------------------------------------------------------- >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] > This email and any attachments are strictly confidential and are intended solely for the addressee. If you are not the intended recipient you must not disclose, forward, copy or take any action in reliance on this message or its attachments. If you have received this email in error please notify the sender as soon as possible and delete it from your computer systems. Any views or opinions presented are solely those of the author and do not necessarily reflect those of HPD Software Limited or its affiliates. At present the integrity of email across the internet cannot be guaranteed and messages sent via this medium are potentially at risk. All liability is excluded to the extent permitted by law for any claims arising as a re- sult of the use of this medium to transmit information by or to HPD Software Limited or its affiliates. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <font face="Times New Roman" size="3"> <p>------------------------------------------------------------------------------</p> <p> This e-mail may be privileged and/or confidential, and the sender does not waive any related rights and obligations. Any distribution, use or copying of this e-mail or the information it contains by other than an intended recipient is unauthorized. If you received this e-mail in error, please advise me (by return e-mail or otherwise) immediately.</p> <p> Ce courriel est confidentiel et prot�g�. L'exp�diteur ne renonce pas aux droits et obligations qui s'y rapportent. Toute diffusion, utilisation ou copie de ce message ou des renseignements qu'il contient par une personne autre que le (les) destinataire(s) d�sign�(s) est interdite. Si vous recevez ce courriel par erreur, veuillez m'en aviser imm�diatement, par retour de courriel ou par un autre moyen.</p> <p>====================================================</p> </font>
