These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Hibernate Query with expression like '%?%'
PostPosted: Tue Jul 12, 2005 9:16 am 
Newbie

Joined: Tue Jul 12, 2005 9:04 am
Posts: 13
Hi guys!

Im using Hibernate Query with Positional Parameter (like JDBC PreparedStatement '?'). When I try to use the expression '%?%' like " ...where table.name like '%?%' ", an error occurs .
The hibernate version is 2 and I am using Java5.

Code:
net.sf.hibernate.exception.GenericJDBCException: Could not execute query
   at net.sf.hibernate.exception.ErrorCodeConverter.handledNonSpecificException(ErrorCodeConverter.java:90)
   at net.sf.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:79)
   at net.sf.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
   at net.sf.hibernate.impl.SessionImpl.convert(SessionImpl.java:4131)
   at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1557)
   at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:49)
   at com.nexxera.pagamento.persistence.facade.pagamento.PagamentoFacadeImpl.montarObjetoQueryListarPagamentos(PagamentoFacadeImpl.java:855)
   at com.nexxera.pagamento.persistence.facade.pagamento.PagamentoFacadeImpl.listarPagamentos(PagamentoFacadeImpl.java:425)
   at com.nexxera.pagamento.persistence.facade.pagamento.TestDbUnitPagamentoFacadeImplTeste2.listarPagamentosComFavorecido(TestDbUnitPagamentoFacadeImplTeste2.java:297)
   at com.nexxera.pagamento.persistence.facade.pagamento.TestDbUnitPagamentoFacadeImplTeste2.testListarPagamentosComPagador(TestDbUnitPagamentoFacadeImplTeste2.java:122)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at junit.framework.TestCase.runTest(TestCase.java:154)
   at junit.framework.TestCase.runBare(TestCase.java:127)
   at junit.framework.TestResult$1.protect(TestResult.java:106)
   at junit.framework.TestResult.runProtected(TestResult.java:124)
   at junit.framework.TestResult.run(TestResult.java:109)
   at junit.framework.TestCase.run(TestCase.java:118)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:474)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:342)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:194)
Caused by: java.sql.SQLException: ORA-00911: invalid character

   at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
   at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
   at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:579)
   at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1894)
   at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteDescribe(TTC7Protocol.java:831)
   at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:2496)
   at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2840)
   at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:608)
   at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:536)
   at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:89)
   at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:880)
   at net.sf.hibernate.loader.Loader.doQuery(Loader.java:273)
   at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:138)
   at net.sf.hibernate.loader.Loader.doList(Loader.java:1063)
   at net.sf.hibernate.loader.Loader.list(Loader.java:1054)
   at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:854)
   at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1554)
   ... 18 more


I can't use Criteria because dont support left alter join.

Anybody can help-me? What I made wrong?!

ty for any help!

_________________
Elton Kuzniewski
http://www.eltonk.com.br


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 12, 2005 10:20 am 
Expert
Expert

Joined: Wed Apr 06, 2005 5:03 pm
Posts: 273
Location: Salt Lake City, Utah, USA
I was going to tell you how you should search the forums for answers to your questions before posting, since it has been answered many times, but I tried it just now and noticed that the search seems to be broken. Anything I search for comes up with no matches.

Here's a link to a previous thread on this topic:

http://forum.hibernate.org/viewtopic.php?t=943637&highlight=


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 12, 2005 10:28 am 
Newbie

Joined: Tue Jul 12, 2005 9:04 am
Posts: 13
I've been tried to search in forum, but it really dont work :(

_________________
Elton Kuzniewski
http://www.eltonk.com.br


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 12, 2005 10:33 am 
Newbie

Joined: Tue Jul 12, 2005 9:04 am
Posts: 13
nathanmoon,
This solution works fine, except if I inject quote in the positional parameter.
How can I resolve it?!

Ty :)

_________________
Elton Kuzniewski
http://www.eltonk.com.br


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 12, 2005 11:17 am 
Expert
Expert

Joined: Wed Apr 06, 2005 5:03 pm
Posts: 273
Location: Salt Lake City, Utah, USA
I don't remember off the top of my head. I remember reading a posting about it a while back, but since the search seems to be broken...

I believe there is some way to specify an escape character, and then use that escape character to escape the quote. Sorry I can't be of more help. Try searching again later when the forum gets fixed.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.