Parameter « HQL « JPA Q&A





1. Second replacement of a named parameter fails in HQL    stackoverflow.com

I have an HQL statement of this sort:

update versioned MyTable t 
set t.myCol = case 
   when ((t.myCol + :myColChange) < 0) then 0 
   else (t.myCol ...

2. HQL - Remember that ordinal parameters are 1-based?    stackoverflow.com

I'm trying to match a hibernate entity via by DAO class, the first method works but the second 'findByMatchingName()' fails with the exception below. What's wrong with this clause '%?%'> ?

public ...

3. Parameter not being set in HQL    coderanch.com

I have a method call: project = ( Project_BC ) session.createQuery("from Project_BC where projectId =?").setLong( 0, longValue ).uniqueResult(); which throws the following exception: Encountered exception while executing runInsert: org.hibernate.exception.GenericJDBCException: could not execute query at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter .java:103) at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) at org.hibernate.loader.Loader.doList(Loader.java:2148) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029) at org.hibernate.loader.Loader.list(Loader.java:2024) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:375) at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:308) at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:153) at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1106) at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79) at org.hibernate.impl.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:749) at com.msdw.pbefficiency.servicestracker.dao.BussConsDAO.getProjectByProjId(Unknown Source) ...

4. Problem when I use parameters into HQL    forum.hibernate.org

I am trying to use this query: Code: //Recupero la sessione da Hibernate Session session = sessionFactory.getCurrentSession(); logger.debug("Il nome della licenza e': "+nomelicenza); String textQuery = "from Vocelicenza as v where v.voceLicenza = :nomelicenza"; ...

5. HQL using 'in' named parameter    forum.hibernate.org

Hi I'm trying to use the an 'in' statement where the values are passed in by the application. my select is as follows select ass.comp_id.name, ass.comp_id.description from Assignments ass where ass.busCode in :busCodes where :busCodes is a Collection of String objects now i have tried the following to no avail select ass.comp_id.name, ass.comp_id.description from Assignments ass where ass.busCode in elements(:busCodes) and ...

6. *Not* escaping parameters in HQL    forum.hibernate.org

7. HQL named parameter in Hibernate 3.1    forum.hibernate.org

I have the following HQL query: select p1_1.id, p1_1.name, p1_1.dob from PatientClinical as p1_1 where (p1_1.id = :A.B) This query works fine in Hibernate 2. It seems that Hibernate 3.1 doesn't like "." characters within HQL named parameters. In Hibernate 3.1 it crashes with a NPE: java.lang.NullPointerException org.hibernate.hql.ast.HqlSqlWalker.lookupProperty(HqlSqlWalker.java:380) org.hibernate.hql.antlr.HqlSqlBaseWalker.addrExpr(HqlSqlBaseWalker.java:4308) org.hibernate.hql.antlr.HqlSqlBaseWalker.expr(HqlSqlBaseWalker.java:1211) org.hibernate.hql.antlr.HqlSqlBaseWalker.exprOrSubquery(HqlSqlBaseWalker.java:4024) org.hibernate.hql.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:3513) org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1758) org.hibernate.hql.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:776) org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:577) org.hibernate.hql.antlr.HqlSqlBaseWalker.collectionFunctionOrSubselect(HqlSqlBaseWalker.java:4235) org.hibernate.hql.antlr.HqlSqlBaseWalker.inRhs(HqlSqlBaseWalker.java:4144) org.hibernate.hql.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:3827) org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1758) org.hibernate.hql.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:776) org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:577) ...

8. HQL with "in" and Parameter    forum.hibernate.org

public List findByRecordIds(Collection recordIds) { return getSession() .createCriteria(Taxa.class) .add(Restrictions.in("recordId", recordIds)) ...

9. HQL with positional parameters and NOT IN    forum.hibernate.org

Need help with Hibernate? Read this first: http://www.hibernate.org/ForumMailingli ... AskForHelp Hibernate version: 3.2.6 Database version: Oracle 9 Hi Im trying to run an HQL query that uses both positional characters and the NOT IN statement and it's not returning the correct results. The statement is along the lines of select o.column1 from TABLEA o where o.column2 = ? AND o.column3 not ...