Hi Jakob, >>how does sql handle like with integers ?
No problem, the following works fines: "select * from products where internal_product_id like '%25%'" Rgds, John -----Original Message----- From: Jakob Braeuchi [mailto:[EMAIL PROTECTED] Sent: 26 February 2003 19:03 To: OJB Users List Subject: Re: addLike and integer fields hi john, how does sql handle like with integers ? jakob O'Reilly John wrote: >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(OraclePreparedStatemen t >.java:2021) at >oracle.jdbc.driver.OraclePreparedStatement.setObject(OraclePreparedStatemen t >.java:2102) at >com.p6spy.engine.spy.P6PreparedStatement.setObject(P6PreparedStatement.java : >282) at >org.apache.ojb.broker.platforms.PlatformDefaultImpl.setObjectForStatement(P l >atformDefaultImpl.java:229) at >org.apache.ojb.broker.platforms.PlatformOracleImpl.setObjectForStatement(Pl a >tformOracleImpl.java:126) at >org.apache.ojb.broker.accesslayer.StatementManager.bindStatementValue(State m >entManager.java:258) at >org.apache.ojb.broker.accesslayer.StatementManager.bindStatement(StatementM a >nager.java:297) at >org.apache.ojb.broker.accesslayer.StatementManager.bindSelectionCriteria(St a >tementManager.java:490) at >org.apache.ojb.broker.accesslayer.StatementManager.bindStatement(StatementM a >nager.java:451) at >org.apache.ojb.broker.accesslayer.JdbcAccessImpl.executeQuery(JdbcAccessImp l >.java:258) at >org.apache.ojb.broker.accesslayer.RsIterator.<init>(RsIterator.java:175) >at >org.apache.ojb.broker.singlevm.RsIteratorFactoryImpl.createRsIterator(RsIte r >atorFactoryImpl.java:95) at >org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getRsIteratorFromQuery ( >PersistenceBrokerImpl.java:2146) at >org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getIteratorFromQuery(P e >rsistenceBrokerImpl.java:1550) at >org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuery(P e >rsistenceBrokerImpl.java:1235) at >org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuery(P e >rsistenceBrokerImpl.java:1363) at >org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuery(P e >rsistenceBrokerImpl.java:1389) at >org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuery(P e >rsistenceBrokerImpl.java:1376) at >org.apache.ojb.broker.singlevm.DelegatingPersistenceBroker.getCollectionByQ u >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] > > > > --------------------------------------------------------------------- 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]
