createQuery « Query « JPA Q&A





1. Null Pointer on Hibernate's createQuery()    stackoverflow.com

I'm struggling to get to the bottom of a null pointer exception that happens when I try to run a HQL query with createQuery(). The code to run the query is pretty ...

2. Hibernate createQuery    stackoverflow.com

I am running this in a junit test:

final Query queryHist = getSession().createQuery(sb.toString());
and sb contains the following HQL:
select distinct r from Historic hist, Registry r 
where 
( 
  (hist.fromm >=:fromDate and ...

3. CreateQuery / Session.get is not returning objects    forum.hibernate.org

When I invoke getJbossPortal() method, it returns Number of Objects fetched as zero. I tried with get method also like this : Jbossportal jbs=(Jbossportal) session.get(Jbossportal.class, id.trim()); But it returns null. I am struggling with this for the past 2 days. Any help is highly appreciated. I have given my dao source and xml file contents below: DAO Class: public class JbossportalDAO ...

4. Envers auditReader.createquery help needed    forum.hibernate.org

Hi All, I am working with hibernate 3.5.3 and Envers that comes with it. I am trying to make auditreader querries to coem up with results: My RevisionEntity is customized and looks like this: Code: @RevisionEntity(LossShareEnversListener.class) public class LossShareRevisionEntity { @RevisionNumber private int id; ...

5. createQuery and specific fiields    forum.hibernate.org

Hi, Im new to Hibernate and not sure (also after reading documentation) what the best way to go is. In my code I have specified to execute the following query: Code: List results = em.createQuery("select a from Auction a where lower(a.name) like #{auctionSearchNamePattern}") .setMaxResults(pageSize + ...

6. getting distinct Result set using HQL createquery    forum.hibernate.org

i want to get the distinct results. i am using the following HQL. for it. this is a one to many relation ship i which student can take admission in many courses. the hbm code for it is Code: ...

7. CreateQuery vs CreateSQLQuery    forum.hibernate.org

Hi all, New to hibernate and have a question. The following works just fine; List Users = session.CreateQuery("from users").list(); Iterator i = Users.iterator(); while (i.hasNext()){ Users usr = (Users) i.next(); System.out.println(usr.getName()); } but when i try List Users = session.CreateSQLQuery("SELECT * FROM Users").list(); I get an error message here: Users usr = (Users) i.next(); <--- complained about casting object to User!! ...

8. using createQuery(), HQL where clause dumped straight to SQL    forum.hibernate.org

Beginner Joined: Tue Oct 04, 2005 8:09 am Posts: 22 Location: Atlanta, USA Hi everyone, I'm having trouble getting a simple HQL query to work. The query's where clause is getting dumped straight into the generated SQL without translating field names into column names. For example, I've got a field called codeName mapped to the column CODE_NAME. Original HQL: from States ...

9. I'm not able to use createquery    forum.hibernate.org

Newbie Joined: Fri Sep 19, 2003 5:06 am Posts: 4 Hi all, I'm very new to hibernate and I'm trying a simple program to get it working. I have an oracle db and I put a table db_obj in it. here is my hibernate xml ...





10. Query/createQuery() usage with setXXX() methods    forum.hibernate.org

Make sure to use a 0 based value as the first parameter in the setXXX() methods used on the Query object when setting parameterized values instead of being 1 based. Example: Query query = session.createQuery(" from Widget as widget where widget.persistence = ? " ); setString( 1, "hibernate" ); //hibernate does not like you setString( 0, "hibernate" ); //hibernate likes you ...

13. createQuery problem    forum.hibernate.org

Hi All, Maps: Code: ...

14. session.createQuery ERROR    forum.hibernate.org

15. createQuery - count(*) returning null    forum.hibernate.org

String sql = "from Contact where UserId = 1893"; Query query = sess.createQuery(sql); Long counter = (Long) query.uniqueResult();

16. use of setInteger with createQuery    forum.hibernate.org





17. use of setInteger with createQuery    forum.hibernate.org

18. The method createQuery is deprecated?    forum.hibernate.org

19. AccessControlException - session.createQuery    forum.hibernate.org

Need help with Hibernate? Read this first: http://www.hibernate.org/ForumMailingli ... AskForHelp Hibernate version: 3 In dao I am creating HQL query and have AccessControlPermission...What wrong? I am using Sun JSAS 8.1 javax.ejb.EJBException at com.sun.ejb.containers.BaseContainer.processSystemException(BaseContainer.java:2807) at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:2713) at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:2521) at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:819) at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:137) at $Proxy69.createAccount(Unknown Source) at TestServlet.processRequest(TestServlet.java:37) at TestServlet.doGet(TestServlet.java:56) at javax.servlet.http.HttpServlet.service(HttpServlet.java:747) at javax.servlet.http.HttpServlet.service(HttpServlet.java:860) 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) ...

20. createQuery launches an update ?    forum.hibernate.org

System.out.println("Start"); List l = HibernateUtil.getSession() .createQuery("from Entidad where idAnualidad = ?") .setInteger(0, idAnualidad) .list(); ...

21. Error parser when I try delete using createQuery    forum.hibernate.org

Hi, I want to delete the content from a table. I am doing this: session.createQuery("delete MyTable").executeUpdate(); But it throw a exception: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 at java.util.ArrayList.RangeCheck(ArrayList.java:507) at java.util.ArrayList.get(ArrayList.java:324) at org.hibernate.hql.ast.HqlSqlWalker.postProcessDelete(HqlSqlWalker.java:418) at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:175) at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:189) at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:130) at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:83) at org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:427) at org.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:884) at org.hibernate.impl.SessionImpl.executeUpdate(SessionImpl.java:865) at org.hibernate.impl.QueryImpl.executeUpdate(QueryImpl.java:89) at sadiel.sigeta.datos.ResponsableClienteDatos.delete(ResponsableClienteDatos.java:197) at com.sadiel.sigeta.actions.MantenimientoClienteAction.guardar(MantenimientoClienteAction.java:144) 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:324) ...

22. Basis createQuery problem    forum.hibernate.org

Yeah, I know it looks stupid. But I'm creating a framework, and the framework creates a html navigatable table (next, previous). I send the following query to my framework classes: select s.id as id, s.code as code, s.name as name from Service s But i also want to display the record count, this is why I want to use this query. ...

23. createQuery with 2 ?    forum.hibernate.org

24. InvocationTargetException in session.createQuery("from    forum.hibernate.org

Exception in thread "main" java.lang.reflect.UndeclaredThrowableException at $Proxy0.createQuery(Unknown Source) at events.EventManager.listEvents(EventManager.java:79) at events.EventManager.main(EventManager.java:18) Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:292) ... 3 more Caused by: ...

25. Hibernate Problem on session.createquery line    forum.hibernate.org

Hi Forum, I am very new to hibernate so let me know if you need more information. We have Struts based application and using hibernate 3.0. Our application runs fine for few users but when around 10 users log in and access it .it crashes after a while. I am posting error log. I will appreciate if anybody has any idea ...

26. CreateQuery vs. find    forum.hibernate.org

Hi, I am using Hibernate 2.1.7 and I noticed a weird behavior. I query a database using sess.createQuery(hql).setLong(0, parameter).list() and it is taking a long time, then I replaced it for sess.find(hql, new Object[] {parameter}, new Type[] {Hibernate.Long}) and it still took a long time. When I created I a hard coded string (hql) with the parameters and called sess.find(hql) the ...

27. [solved] Problem with createQuery in the reference tutorial    forum.hibernate.org

Hi guys, I'm new to hibernate so i started to follow the instructions in the reference tutorial on http://www.hibernate.org/hib_docs/v3/re ... orial.html . Instead of HSQLDB I'm using MySQL 5.0 with Hibernate 3.1.3. Up to section 1.2.6 everything just works fine. The database tables are generated automatically and the event objects get stored well. But when I'm trying to execute Code: List ...

28. unexpected token error when executing insert for createQuery    forum.hibernate.org

Hi, I am using hibernate 3.1.3. I want to execute an insert statement using createQuery method. When I execute it gives me an error. Does insert is not supported using createQuery method? Query query = session.createQuery("INSERT INTO Test (id, id2) VALUES (?, ?)"); query.setParameter(0, 100); query.setParameter(1, 101); int numInserted = query.executeUpdate(); [java] Caused by: org.hibernate.hql.ast.QuerySyntaxException: unexpected token: VALUES near line 1, ...

29. session.createQuery() error on jdk131 - urgent    forum.hibernate.org

amurugan Post subject: session.createQuery() error - SOS!! Posted: Mon Jun 19, 2006 11:12 am Newbie Joined: Wed Jun 07, 2006 3:21 pm Posts: 13 Hi Lili , Thanks for the reply . I tried specifying the type as date . Please find my verbose log from hibernate . I am able to insert , delete but unable to select ...

30. session.createQuery() error SOS !!    forum.hibernate.org

Author Message amurugan Post subject: session.createQuery() error SOS !! Posted: Mon Jun 19, 2006 11:17 am Newbie Joined: Wed Jun 07, 2006 3:21 pm Posts: 13 Need help with Hibernate? Read this first: I am getting a MethodNotFoundError while executing session.createQuery() . I am able to insert , delete using the POJO but unable to select . JDK- 131 ...

31. Help -- Problem with createQuery()    forum.hibernate.org

Newbie Joined: Thu Jul 06, 2006 3:07 pm Posts: 9 I am using Hibernate 3.1.3. I am new to Hibernate. I have read the documentation on Hibernate's website. I am creating a Delete Query and getting this error when I invoke session.createQuery(...) from my Web Application. I don't get this error when I run my code from a static main method. ...

32. createQuery question    forum.hibernate.org

I have tried SQLQuery now instead: Code: SQLQuery query = session.createSQLQuery("SELECT localArea.* from LocalArea localArea" + " JOIN WideArea wideArea join Country country " + " on wideArea.wideAreaID=localArea.wideAreaID and country.countryID=wideArea.countryID " + ...

33. How to refresh a ArrayList from a createQuery ?    forum.hibernate.org

hi, I don't think refresh() is intended for refreshing lists: efresh: Re-read the state of the given instance from the underlying database. It is inadvisable to use this to implement long-running sessions that span many business tasks. This method is, however, useful in certain special circumstances. For example

    - where a database trigger alters the object state upon insert or ...

34. createQuery exception???    forum.hibernate.org

Need help with Hibernate? Read this first: http://www.hibernate.org/ForumMailingli ... AskForHelp Hibernate version: 3.0 Mapping documents: Code: ...

35. HQL - createQuery Date Compare    forum.hibernate.org

Is there a way to compare dates using HQL where you can someone string the query together in a string. I know about setParameter but I would like to string together a query purely string I want to be able to build a filter based on string only Query summaryQuery = session.createQuery("from DPHeaderVO " + sqlSuffix); where sqlSuffix would be a ...

36. HQL - createQuery Date Compare    forum.hibernate.org

Is there a way to compare dates using HQL where you can someone string the query together in a string. I know about setParameter but I would like to string together a query purely string I want to be able to build a filter based on string only Query summaryQuery = session.createQuery("from DPHeaderVO " + sqlSuffix); where sqlSuffix would be a ...

37. createQuery help needed    forum.hibernate.org

38. Exception on createQuery    forum.hibernate.org

39. Different Result from createQuery and createSQLQuery    forum.hibernate.org

Hi, I have a mytable whose columns in hbm are defined as below Table Data name age John 10 Peter 20 I want run simple query as select sum(age), count(name) from mytable the output at database end is 30, 2 Problem is when i try to execute same query using createSQLQuery of hibernate ...

40. session.createQuery() problem    forum.hibernate.org

WHY THIS CODE: StringBuffer queryString = new StringBuffer(); queryString.append("select lr.id, count(lre.leadingRecord) "); queryString.append("from LeadingRecord lr "); queryString.append("left outer join lr.leadingRecordErrors lre "); queryString.append("group by lr.id "); queryString.append("order by lr.id asc"); Session session = HibernateUtilSUNCE.getSession(); try { Query query = session.createQuery(queryString.toString()); query.list(); }... GENERATE FOLLOWING SQL: select leadingrec0_.ID as col_0_0_, count(leadingrec1_.LRER_LDRE_ID) as col_1_0_ from LEADING_RECORD leadingrec0_, LEADING_RECORD_ERROR leadingrec1_, LEADING_RECORD leadingrec2_ where leadingrec0_.ID=leadingrec1_.LRER_LDRE_ID(+) ...

41. createQuery problems    forum.hibernate.org

Hi! I'm getting this exception and can't locate what is wrong: Code: org.hibernate.QueryException: ClassNotFoundException: org.hibernate.hql.ast.HqlToken [from com.test.model.User where userId = ?] org.hibernate.hql.ast.HqlLexer.panic(HqlLexer.java:57) antlr.CharScanner.setTokenObjectClass(CharScanner.java:340) org.hibernate.hql.ast.HqlLexer.setTokenObjectClass(HqlLexer.java:31) antlr.CharScanner.(CharScanner.java:51) antlr.CharScanner.(CharScanner.java:60) org.hibernate.hql.antlr.HqlBaseLexer.(HqlBaseLexer.java:56) org.hibernate.hql.antlr.HqlBaseLexer.(HqlBaseLexer.java:53) org.hibernate.hql.antlr.HqlBaseLexer.(HqlBaseLexer.java:50) org.hibernate.hql.ast.HqlLexer.(HqlLexer.java:26) org.hibernate.hql.ast.HqlParser.getInstance(HqlParser.java:44) ...

42. session.createQuery(...) hung up    forum.hibernate.org

Hi, I've got strange problem with Hibernate used as database persistence system when invoking a few database queries in separate jobs. My screnario looks this way: I have a class called LogonManager (extends Job) which calls about 10 job steps using: protected IStatus run(final IProgressMonitor monitor) { final IWorkbench workbench = PlatformUI.getWorkbench(); final IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); final Shell shell = ...

43. Query.createQuery creates 2 selects instead of 1    forum.hibernate.org

If I call Query.createQuery Hibernate creates 2 Select statements. The first one is the expected statement but its followed by a second statement that quite different from the origin. It contains a where condition that asks only for 1 id. The query joins 3 tables which have a 1-n relation (bidirectional): table1 -- 1-n -- table2 -- 1-n -- table3. I ...

44. Get column names from session.createQuery    forum.hibernate.org

...

UsernameCount

45. Wrong query output using createQuery    forum.hibernate.org

So, your list should be a collection of MyJavaObject types, correct? The list is holding lazy objects, that need to be cast into the appropriate type. A list.get(0).getClass() would tell you exactly what class type the list contains. You might want to print that information to the console, assuming of course at least one record is returned. Otherwise you'll get an ...

46. Can I specify join in createQuery()?    forum.hibernate.org

It seems like that HQL does not recognize "inner join on" syntax. It accepts inner join, but if you specify "on" condition, it blows up. I understand how to define OneToOne, OneToMany etc in JPA, but is that the only way? what if I want to specify join in my createQuery() call?

47. Problem with createQuery and createSQLQuery methods    forum.hibernate.org

jdbc:mysql://localhost/hibernate root root com.mysql.jdbc.Driver org.hibernate.dialect.MySQLDialect true true update