hql 3 « HQL « JPA Q&A





1. HQL question    forum.hibernate.org

Hibernate will return a list of Users. Presumably you have set up User to contain a collection of Roles (via the UserRoles join table). So user.getRoles() will return the collection of a user's roles. Remember, Hibernate is an ORM. It doesn't load database rows, it loads objects. If objects contain references to other objects, hibernate loads those, too. You don't need ...

2. HQL Help needed    forum.hibernate.org

3. Need help. HQL    forum.hibernate.org

String query = "from Area l where ((l.minX >= :minX) and (l.maxX <= :maxX) and (l.minY >= :minY) and (l.maxY <= :maxY)) or (not ((l.maxX < :minX) or (l.minX > :maxX) or (l.maxY < :minY) or (l.minY > :maxY))) and (:pixelWidth * abs(l.maxX - l.minX) / :parentWidth >= :limitWidth) and (:pixelHeight * abs(l.maxY - l.minY) / :parentHeight >= :limitHeight)";

4. another question about hql.g    forum.hibernate.org

in hql.g,the expressionOrVector rule deal with the expression wraped by the open-close('()').for example ," select (a) from.."will be validate and "select (a,b) from.." also .but for the sql sentence,the "select (a) from.." can be work ,and the "select (a,b) from.." will be error. in my opinion,the primaryExpression rule useing the expressionOrVector rule should change to use just expression rule. can somebody ...

5. Help with HQL.    forum.hibernate.org

6. need a help in HQL    forum.hibernate.org

hi all this my HQL code select distinct g.gpName from EmpGroupVO eg inner join GroupVO g g.gpId = eg.gpId where g.gpId not in (select gpId from EmpGroupVO where emp_id = :id) but i'm getting error when i try to retreive anyone plz help me the error is Caused by: org.hibernate.hql.ast.QuerySyntaxException: unexpected token: = near line 1, column 107 [select distinct g.gpName ...

7. Help with HQL    forum.hibernate.org

8. HQL question    forum.hibernate.org

Thanks! In this case my existing Entity0 does not contain objects of the other two types. The tables just have some loose relations based on the column values and i have to check to make sure the column values match up (see my SQL statement above) and only return those rows that are related to the other two tables in that ...

9. HQL integer division    forum.hibernate.org

[b]Hibernate version:3.1[/b] [b]Name and version of the database you are using: MySQL 5.0.18[/b] Hello all. I'm executing a HQL query wich divides two integers and I want to obtain a double result, just like SQL does, but I see that HQL is doing an integer division (like java). I try with 'cast (property as double)' but the cast to double doesn't ...





10. Using .setResultTransformer combined with HQL    forum.hibernate.org

11. HQL problem :NoSuchMethodException    forum.hibernate.org

I have hibernate 3.0 and I have a HQL written as follows:- My Mapping xml is like this :- ...

12. HQL questions    forum.hibernate.org

Hi Guys, I'm trying to do some "select x, y from entity" hql-queries, with strange results. would be great if someone could explain me why that is so, and what I could do better. I've got the entities Line, MillRoll and DataPoint. Line has sets "millRolls" and "dataPoints". Line has also got an id and string property "name". now for the ...

13. Question on HQL    forum.hibernate.org

Hi, How can I convert the following query into HQL? select * from m_tran mt inner join m_process mp on mt.id = mp.id where mp.type = 'ABCD' and mp.status = 'EFGH'; Essentially all I'm looking for is a list of objects which represent m_tran table based on the above criteria. Also, can we use the Criteria* classes for this kind of ...

14. HQL vs OQL/ODMG standards    forum.hibernate.org

15. distinc in HQL    forum.hibernate.org

Hi, I have the following query select distinct parent from parent left join fetch child where parent.name like ? return getSession() .createQuery(hqlString) .setString("searchString",name) .setFirstResult(startPosition) .setMaxResults(maxResult) .list(); I keep getting duplicate parent back if parent has 1 or more children. is the SQL correct? How to use distinct correctly? The child is a set in parent defined in parent.hbm.xml.

16. Need help on HQL    forum.hibernate.org

With the following mapping xml, I would like to retreive the order and order_detail inside the order object that are backorder more than 30 days. I can use the where clause in the mapping file to hard code the 30 days. But is it possible to make this dynamic ? i.e. order 1 has 50 order_details. 20 of the order_details are ...





17. Mixing Lucene FullTextQuery and HQL?    forum.hibernate.org

18. Subselects not usable in HQL case when or arithmetic    forum.hibernate.org

I recently discovered that subselect queries cannot be used within case statements according to the HQL grammar, however, this is definitely supported by MySQL, and a cursory search seems to confirm that it is supported in most DB's. I found a post relating to a similar issue, only with arithmetic combinations of subselect results, which I had also tried to use ...

19. Newbie - Writing a hql    forum.hibernate.org

We need to see the underlying classes and mapping files. I do notice that your original query uses different tables in the joins, but you are using a single table in your HQL query. Also, you are using column names in the your hql, you should only be using method names and the . notation for embedded properties. Ex. Code: class ...

20. One Question regarding HQL    forum.hibernate.org

Dear All I have a question regarding HQL as below. Customer:Contact is 1:1 Contact:Address is 1:n Address:PhoneAdress is 1:1 Address:PostAddress is 1:1 PhoneAddress.medium is "PHONE" PostAddress.medium is "MAIL" PhoneAddress and PostAddress are both subclass of Address I just need to find Customer who has no PhoneAddress For example , if a Customer having both PhoneAddress and PostAddress ,then this Customer could ...

21. HQL Comments    forum.hibernate.org

Is there any way of embedding comments in HQL code that I am missing? It would be a very nice feature as I'm using some fairly large queries to generate reports, and without inline documentation they'll look a bit intimidating to the next programmer who has to deal with them. As with so many queries they are comprised of simple blocks, ...

22. HQL works in 3.1 but not 3.2    forum.hibernate.org

Hi, could anyone tell me what's wrong with this query pls? Code: It works in 3.1, but I upgraded to 3.2 to get an unrelated bug fix, and the HQL isn't valid any more. I ...

23. HQL question    forum.hibernate.org

24. Is that possible execute an "HQL script" with mult    forum.hibernate.org

Hi folks, I'm needing to perform an HQL that looks like this one: update Tab1 set prop1=x, prop2=y; update Tab2 set prop1=x, prop2=y; ... update TabN set prop1=x, prop2=y All classes Tab1, Tab2,...,TabN have the same propertie names, with the same types. These properties will have the same values set (x and y). I'd like to know if it is possible ...

25. Help with HQL    forum.hibernate.org

26. Using true and false in HQL    forum.hibernate.org

27. can anybody help me about the HQL?    forum.hibernate.org

28. HQL question    forum.hibernate.org

Author Message tmk Post subject: HQL question Posted: Fri May 25, 2007 9:41 am Beginner Joined: Thu Mar 29, 2007 11:57 am Posts: 27 Hello, I want to make a query which returns an object of type ImportedGeometries. The query is based on three parameters: - name - version - country Here is the source of this class: Code: ...

29. is there a way to parse HQL?    forum.hibernate.org

hmmm i dont get you....your criterias can be as complex as you want...at the end you have different possibilities... using the criteria API and not HQL using HQL using native SQL... But in all the cases you need to gather the criterias and add them in the first case or change the HQL/SQL-String... No API will help you specify your problem ...

30. HQL brackets question    forum.hibernate.org

Author Message adamgibbons Post subject: HQL brackets question Posted: Wed Jun 06, 2007 7:36 am Senior Joined: Sat Apr 21, 2007 11:01 pm Posts: 144 Hi all, I have an issue with brackets not appearing in the SQL made from this HQL. =( This causes undesired results to be returned. I have the following dynamic HQL generated: Code: select ...

31. HQL help    forum.hibernate.org

Trying to write a query to get a user by email address. I have the following and am getting the error below: Hibernate version: 3.2.3

32. Hibernate HQL    forum.hibernate.org

33. Need Help with HQL    forum.hibernate.org

Hi, I am having a hard time to write the HQL for this senario I have two classes Form and FormVersion. Form has a unidirectional one-to-many relation with FormVersion. FormVersion has all the attributes of the form like name, description, ... If i want to retrieve a form attribute i have to do form.getFormVersions() which returns a collection of FormVersion objects ...

34. Help on a HQL Request    forum.hibernate.org

35. HQL Help    forum.hibernate.org

36. HQL problem!    forum.hibernate.org

37. Need some helps on HQL    forum.hibernate.org

38. bit operations in HQL    forum.hibernate.org

Hibernate version: hibernate 3.2 ga MySQL5.0 I want to retrieve objects with a given bit set to 1 in a byte property... is it somehow possible to perform bit operations in the where clause? like: from EcEntityAccess ec where ec.ecEntityByIdSubject.ebtEntityType = 2 and ec.ecEntityByIdPrincipal = :principal and (ec.accessflags & :flags) > 0 In MySQL bit operations seem to be possible, but ...

39. Problem with HQL    forum.hibernate.org

Hibernate version: 3 Code between sessionFactory.openSession() and session.close(): Query query = session.createQuery(" from MyObject where "+ "field1||' '||field2 in ("+ "select field1||' '||field2 from MyObject group by field1||' '||field2 having count(field1||' '||field2) > 1)"); list = query.list() ; Full stack trace of any exception that occurs: org.hibernate.hql.ast.QuerySyntaxException: expecting CLOSE, found '||' near line 1, column 207 [from fr.test.data.MyObject where field1||' '||field2 ...

40. HQL problem    forum.hibernate.org

41. can I use .contains() in a HQL ?    forum.hibernate.org

42. HQL over a timeserie (Querie per Weekday...)    forum.hibernate.org

HI, I'm using hibernate 3 in a Spring environment. The database is MySQL. Now I'm looking for a way to execute the following queries: give me all hits, which have a timestamp where the Day is Monday. or give me all hits, where the timestamp is between 08:00 and 10:00 (all days) Is there a direct way with HQL?? Thank you ...

43. How to APPEND 'WITH CS' to HQL ?    forum.hibernate.org

44. HQL BNF    forum.hibernate.org

45. HQL    forum.hibernate.org

public class User extends BaseObject{ private Long id; private String name; private String location; private String sex; private String birthdate; private List friends; ....... public class Friend extends BaseObject{ private Long id; ...

46. hql vs getById    forum.hibernate.org

47. HQL: how to use 'between' with text field    forum.hibernate.org

I have a table, Address, with a couple fields, 'numStart' and 'numEnd'. When a user searches for Addresses he can specify the Street name and optionally, a Number. I would like to do a query like this: from Address where street.name like ? and and ? between numStart and numEnd The only problem is that 'numStart' and 'numEnd' are TEXT fields, ...

48. Question on ch. 14 (HQL) of the reference manual    forum.hibernate.org

49. How to use hints in hql    forum.hibernate.org

50. hql help    forum.hibernate.org

51. HQL Problem    forum.hibernate.org

i would suggest to add in your mapping two columns rerpresting you mapkey elements as you can notice this is only a read only value. and then write your HQL query romaly. from group g where g.groupmembers.readOnlyMapKey1 = :mapkey1 and g.groupmembers.readOnlyMapKey2 = :mapkey2

52. How get nested DTO from HQL ??    forum.hibernate.org

53. SYSDATE and HQL    forum.hibernate.org

54. Problem with HQL bracket (disjunction)    forum.hibernate.org

Hi all, I am trying to create a query using HQL . I am not sure if it is just a beginner's problem but it really blocks my way. Here is the SQL that I pass into the function getSession().createQuery() (for illustration purpose): select key, val from mytable where ((1=1 and 2=2) or (3=3 and 4=4)) and here is the GENERATED ...

55. HQL to HQL translator    forum.hibernate.org

Hello all. I want to create special query language for my data model (xwiki.org) based on HQL with some rewrites. I need to rewrite FROM and WHERE clause for add implicit joining. So I need some HQL to HQL translator. I found only HQL to SQL translator in hibernate core. I found HqlParser class in hibernate core and it quite suit ...

56. using "case when" structures hql    forum.hibernate.org

Hi, I'm using hibernate 3.2.5 and I would like some advice on the following use case: I want to order a query based on "is null" of some columns, 2 columns is null gives an earlier occurence than 2 columns not null. In oracle 10.? I can do: Code: select * from ( select * ...

57. think for hql    forum.hibernate.org

sorry my english not good,but please look it!! if hql is "from ObjectName o where o.id=value "; return all of the Object's attributes ,not good . if hql is "from ObjectName(attrib1,attrib2) o where ...", return the Object but only contain attrib1,attrib2, others attribute is null. that good. if hql is "from Object1(attrib1,attrib2) o1, Object2(attrib1,attrib3) o2 where o1.id=o2.id" return array[Object1,Object2] and other ...

58. How to add dateformat to hql    forum.hibernate.org

59. Selective HQL    forum.hibernate.org

Hi, I have this query but it not work. What is the problem? What object return this query? Code: "select ci.id," + " ci.area," + " ci.nombre," + ...

60. Support of minus in HQL    forum.hibernate.org

hibernate3.0 Mapping documents: Code between sessionFactory.openSession() and session.close(): 19-Sep 09:27:13 ERROR QueueItemHomeDuplicate unexpected token: minus near line 1, column 369 [from QueueItem queueItem where queueItem.itemType = ? and queueItem.queue.id = ? and queueItem.draftApplication.draftApplicationStatus.id <> ? and queueItem.draftApplication.draftApplicationStatus.id <> ? and queueItem.transaction.transactionStatus.id <> ? and queueItem.transaction.transactionStatus.id <> ? minus select transaction.id from queueItem where queueItem.itemType=? AND queueItem.queue.id=?] org.hibernate.hql.ast.QuerySyntaxException: unexpected token: minus near ...

61. HQL initialise problem    forum.hibernate.org

hi, first of all I guess you should use MappedBy for manytoone relation - that will force hibernate to resolve that relation according to the first one. It should be done like that for bidirectional relations. I use annotations but the example below should help you anyway: class A @OneToMany(mappedBy= "a_prop" ), private Set listofBs ; class B @ManyToOne @JoinColumn(name = ...

62. HQL "OR" Problem    forum.hibernate.org

Newbie Joined: Thu Oct 09, 2008 5:22 am Posts: 1 Hi I am using Hibernate3 with mysql 5.0.51 and I've noticed HQL is evaluating some expressions NOT as I expected. My first query is as follows: query = "select A from ImportAntrag as A where A.originalId='0' and A.antrag_id >= 1346 and A.antrag_id <= 1346 and A.originalImpBokId='0' and A.dienststelle.bundesland=?"; params.add(inspektor.getDienststelle().getBundesland()); Session session ...

63. How to use ROW_NUM in HQL?    forum.hibernate.org

64. HQL question    forum.hibernate.org

I could do the distinct query and then do an additional query for each item, but that seems like way too many queries -- if I have 10 distinct items then I've have to do 1 + 10 queries or 11 scans of the same table(s). I'm surprised I can't do this all in one query that would prevent the redundancy. ...

65. Can HQL do this?    forum.hibernate.org

Hello, I have a SQL with the append data to the column like this... For example, table Student with a "name" column I want make this SQL Select 'Student:' + st.name from Student. the result will be like this 2 records founded with one column Student: Philip Student: John Can I make HQL to do this(I have a Student class with ...

66. param set for yes_no in HQL    forum.hibernate.org

Hi, i have filed type yes_no in my table, i need to find the search based on filed yes_no type. suppose i have table called "sample" and colum name "sex" is yes_no type. how can i construct the HQL using this, and pass the param, am new to Hibernate, if somebody assista grat help for me thanks kathir

67. Mixing JPA with HQL    forum.hibernate.org

I have a configuration with JPA. Everything is fine and working. When i use JPA syntax like this : EntityManagerFactory emf = Persistence.createEntityManagerFactory("pmanager"); EntityManager em = emf.createEntityManager(); Query q = em.createQuery("from foo"); List l = q.getResultList(); OK! - Works. But how do i have to do use Hibernate criteria, Query ? How do i get a Hibernate Session Object ? Or ...

68. HQL not returning single row    forum.hibernate.org

...

69. Is writing HQL supposed to be fast?    forum.hibernate.org

It took me a few minutes to come up with this SQL: select cilocs.name, cilocs.region, colocs.station_code, sl.name from company_locations colocs inner join companies co on colocs.company_id = co.id inner join city_locales cilocs on colocs.city_id = cilocs.city_id inner join locales l on cilocs.locale_id = l.id left join station_locales sl on (colocs.station_code = sl.station_code and cilocs.locale_id = sl.locale_id) where co.active = true and ...

70. Netbeans HQL problem    forum.hibernate.org

Hello , In short terms my problem looks like this : I have a java project made in netbeans . I've mapped my database with hibernate (POJO file) the from 'table' works perfectly for all my tables but when i want to use select from statement i get org.hibernate.QueryException: Unable to resolve path Examples used Clients table ( ClientID FirstName LastName) ...

71. [Ask] How to Run HQL with Hibernate Console?..    forum.hibernate.org

72. Help with a HQL issue    forum.hibernate.org

Hi, I have two classes : class Source and class Post, which has a many to one relationship with Source. In the mapping of Post I therefore have something like : Now in HQL I'm trying to get a list of Source, only I want to limit this list to the Source entities that are associated ...

73. Reason for using HQL in Hibernate    forum.hibernate.org

Hi , Please tell me what is the reason for using HQL , when the same thing can be done with the help of normal SQL query. Sessions createSQLQuery() How does an HQL will improve the performance as it will be internally converted to an SQL Query Itself. Thanks in advance .

74. many-to-one - HQL problem    forum.hibernate.org

I have defined relation for RewardsID in Points History Table as shown below in .hbm.xml file. My requirement is to retrieve points history between particular dates. Given below is the HQL that I am using. select pnt.createdDate, pnt.points, pnt.rewardsChart.name, pnt.rewardsChart.description, from PointsHistory pnt where pnt.createdDate between ? and ? The problem that I am facing with this query is that ...

75. Hibernate HQL Question    forum.hibernate.org

I have 5 tables which are connected PickupLoc, Address, ContactInfo, UsStateCode, CountryCode when i run a query like "from PickupLoc" with show_sql=true If there are 10 rows in PickupLoc, i see 10 induvidual select statements for each Table. That is equal to 50 seperate sql where as the same can be achieved by using a single query which joins 5 tables. ...

76. HQL: how to check if one set is contained within another set    forum.hibernate.org

Hi Everyone, I've got a problem writing a HQL query, I have an object which contains a set of "Berths" and I want all the objects back whos set of "Berths" is contained within a set of "Berths" that I pass to the query. In Java it would look like this Code: Set setParameter = getSomeBerthObjects(); for(NetworkIncident ni : allNetworkIncidents){ ...

77. Any HQL wizards want to help?    forum.hibernate.org

78. ways of executing Hql programmatically ?    forum.hibernate.org

79. LazyInitializationException / HQL    forum.hibernate.org

No, not really. I've been over all those tutorials and javadocs that you refer to by your example - but they don't really give an answer. The thing is that the Criteria query you refer to (from the Criteria API) doesn't necessarily fetch the "kittens" collection. I need to both fetch a collection as well as "filter" on it. However, it ...

80. HQL where trouble    forum.hibernate.org

Hello Community! Anyone who can tell me how to match a string (in the db) containing both numbers [0-9] and separators [ -/()] with a search parameter which only contains numbers? Its like matching a phone number stored with separators with only the digits in the string. In essence I want strings like this to match: 123-1234 should be match by ...

81. HQL compilation in memory    forum.hibernate.org

I have a problem because the objects used for Compilation of a HQL, remain always in the HEAP of my Java Server. I have seen this in the log in this line : 09/03 13:34:21,164 DEBUG [impl.SessionImpl ] : find: FROM Iatrigger2channel WHERE 1=1 AND ITVPLAT_FK =3 AND CHANNELFUNCTIONALID='arte' 09/03 13:34:21,164 DEBUG [engine.QueryParameters ] : named parameters: {} 09/03 13:34:21,164 DEBUG ...

82. HQL - another ilike/lower problem    forum.hibernate.org

83. lightning memory comsumption during hql parsing    forum.hibernate.org

"[ACTIVE] ExecuteThread: '17' for queue: 'weblogic.kernel.Default (self-tuning)'" id=146 idx=0x274 tid=35532 prio=5 alive, daemon at jrockit/vm/Allocator.allocObject(Allocator.java:735)[optimized] at sun/reflect/GeneratedConstructorAccessor127.newInstance([Ljava/lang/Object;)Ljava/lang/Object;(Unknown Source) at sun/reflect/DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)[optimized] at java/lang/reflect/Constructor.newInstance(Constructor.java:494)[optimized] at java/lang/Class.newInstance0(Class.java:350)[inlined] at java/lang/Class.newInstance(Class.java:303)[optimized] at org/hibernate/hql/ast/SqlASTFactory.create(SqlASTFactory.java:211) at ...

84. Questions about HQL    forum.hibernate.org

Hello I have two questions 1)Why in HQL there isn't "INSERT INTO ... VALUES()" only "INSERT INTO ... SELECT" 2)Why when I executing HQL query "UPDATE employee SET address = 'new' WHERE id = 1" the "onPreUpdate (PreUpdateEventListener)" event not invokating, (ofcourse invoikating when I updating object by session.update()) Best regards Mirek

86. HQL doubt    forums.oracle.com