nath wrote:
Using the following query
Query q = session.createQuery("from LocationInfo where path like %"+des+"%" );
but hibernate is throwing exception saying that
unexpected char: '%'
can any body help me, how to use that % functionality with in the creatQuery.
Besides the missing single quotes, you shoud use parameters for this. Like this:
Query q = session.createQuery("from LocationInfo where path like :des" );
q.setParameter("des", "%" + des + "%");
With this you are protected from single quotes appearing in the string, and the DB can do a better job caching the query plan. And with this you no longer need single quotes.
Rate if this helps =).