hql « Data Type « JPA Q&A





1. HQL string matching on complete words?    stackoverflow.com

How do I match complete words in a hibernate HQL query? For example, imagine in our database we have an entry "Sam Adams". Now, given this HQL fragment:

book.character like 'Sam'
I do not match ...

2. What's wrong with this HQL? "No data type for node"    stackoverflow.com

session.createQuery("Select attribute from GoodsSection tgs " +
    "join gs.ascendants ags join ags.attributes attribute " +
    "where attribute.outerId = :outerId and tgs = :section ")
.setString("outerId", pOuterId)
.setEntity("section", ...

3. How to perform date operations in hibernate HQL    stackoverflow.com

I want to perform data time operations using hibernate hql. I want to add and subtract two dates as well as I want to subtract 1 year or 1 month from a ...

4. How to put 'null' into column using HQL?    stackoverflow.com

How to build valid HQL string, which is equivalent to UPDATE table SET field = null WHERE ....

5. Hibernate HQL strange behavior with IS NULL    stackoverflow.com

I have a problem with a HQL query. I want to get all PID that has an administrative sex set to 'M' or no administrative sex (in Java the value is ...

6. java.lang.IllegalStateException: No data type for node: org.hibernate.hql.ast.tree.MethodNode    stackoverflow.com

greetings all, i got this exception in the following method and i don't know why:

List<Date> temps = getCurrentSession()
              ...

7. Restriction in HQL with Date    stackoverflow.com

I have a class auction like

public class Auction  extends LightEntity implements IsSerializable 
{
   private long AuctionId;
   private Date StartTime;
   private Date EndTime;
}
i need to ...

8. HQL "is null" And "!= null" on an Oracle column    stackoverflow.com

Does hibernate convert "column != null" in HQL to a "column is null" in SQL ? Thx

9. hibernate HQL date difference    stackoverflow.com

I want to find all records which maps to object XYZ with following conditions A has date field XyzDateTime (its a time stamp) Now currentTime -xyzDateTime > 20 i want to select ...





10. String matching in HQL    stackoverflow.com

I'm creating an HQL query to filter a grid of data:

string formatString = "Type = {0} AND {1} = '{2}' AND CompletedDate > '{3}' 
  AND CompletedDate < '{4}' AND ...

12. Comparing Dates with HQL    coderanch.com

So I'm trying to run an HQL query which should compare two date values and it's not behaving in the way I'd expect it to. In short, it compares the date values, but seems to ignore the hours, minutes, and seconds. Here's my query: HibernateUtil.getSession().createQuery( "from Foo WHERE activationDate >= :rolloffDate) .setDate(getRolloffDate()).list(); The method "getRolloffDate()" gets a date in the past. ...

13. String to Date Convertion in HQL    coderanch.com

14. HQL date without time    coderanch.com

15. Manipulating time with HQL    forum.hibernate.org

I could not figure out how to manipulate time easily using HQL. I *did* read through the forums and found some hints but what I ended up using was a Criteria: Code: ... Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DAY_OF_MONTH, 0-days); ... Session session = (Session)super.getEntityManager().getDelegate(); Object countObject = session.createCriteria(UsedMonitor.class) .setProjection(Projections.rowCount()) .add(Restrictions.gt("timestamp", ...

16. HQL and is null?    forum.hibernate.org

Why is it that HQL doesn't generated is null for me? If I'm building a HQL query myself why is it that I have to conditionally use "is null only" if the identifier I'm evaluating is null or not? When is it ever desirable to have attribute = null in a query? ie. why is that the default behaviour?





17. Null Values from View through HQL    forum.hibernate.org

I have a master_data table, which has 100 rows of data. I created a view master_data_view in the database, selecting few columns in the master_data table. Now In the java code. String queryString = "from MasterDataView"; List data = entityManager.createQuery(queryString).getResultList(); I get list with the size of 100, but all are null values. Where did the data go. I then switched ...

18. No data type for node: org.hibernate.hql.ast.AggregateNode    forum.hibernate.org

I am pretty new to hibernate. I am trying to run a simple aggregate function and I keep receiving the following error No data type for node: org.hibernate.hql.ast.AggregateNode \-[AGGREGATE] AggregateNode: 'max' Here is the code Code: public static void resetIdField(SessionFactory factory){ Session session = null; try{ session ...

19. Date Difference in minutes in HQL    forum.hibernate.org

20. HQL Recent Date Question    forum.hibernate.org

Sorry if this is a silly question. I want to retrieve objects from the database where I get last last two months of the objects (based on a property of the object). For example, if it's August, and there are objects in the database for April, May, June and July (but not August), I want to retrieve the objects from June ...

21. newbie stuck on Date manipulation in HQL    forum.hibernate.org

Date d = new Date(); Timestamp ts = new Timestamp(d.getTime()); String hqlString = "select obj from Object as obj where obj.TimestampField < :timeStampField"; Query query = session.createQuery(hqlString); query.setTimestamp("timeStampField",ts); List list = query.list();

22. String Concat in HQL    forum.hibernate.org

23. [HQL] : getting 0 (zero) instead of Null...    forum.hibernate.org

dear all... while getting a sum of a Field(Double) from DB, i get sometimes NULL when the query unsatisfies the conditions. To avoid getting NULL at such times, i have used my query like this... select if(sum(TripSheet.TotalDistance),sum(TripSheet.TotalDistance),0) from routing.cab.domain.TripSheet TripSheet where TripSheet.Cab=3. while trying this i get the error below... (i want the query to return Zero(0) when it is NULL) ...

24. Howto hardcode string on HQL    forum.hibernate.org

select myField, 'foo' as MyField2 from MyTable; How can I do that in HQL? I tried different things such as: select o.field, 'foo' as foo from MyClass o select o.field, "foo" as foo from MyClass o select o.field, new java.lang.String("foo") as foo from MyClass o but all I get is QueryException "undefined alias" on 'foo'. Any ideas? Thank you in advance! ...

25. Help with HQL string concatenation    forum.hibernate.org

26. Why this kind of HQL returns a null set?    forum.hibernate.org

27. Oracle date subtraction in HQL    forum.hibernate.org

Caused by: net.sf.hibernate.QueryException: , expected in SELECT [SELECT hg.closedDate-hg.createdDate FROM com.verisign.mss.storage.TicketStats hg] at net.sf.hibernate.hql.SelectParser.token(SelectParser.java:169) at net.sf.hibernate.hql.ClauseParser.token(ClauseParser.java:87) at net.sf.hibernate.hql.ClauseParser.end(ClauseParser.java:114) at net.sf.hibernate.hql.PreprocessingParser.end(PreprocessingParser.java:143) at net.sf.hibernate.hql.ParserHelper.parse(ParserHelper.java:30) at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:149) at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:138) at net.sf.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:295) at net.sf.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1571) at ...

28. HQL And Dates    forum.hibernate.org

I'm using Hibernate 3 and I want to write HQL to group data by month but I have no idea how to do this and would prefer to not use native SQL. Here's an example, if I have this table... MEMBER id name registeredDate 1 aaa 05-14-2005 14:03:01 2 bbb 04-19-2003 19:09:16 3 ccc 05-27-2005 08:30:42 4 ddd 11-13-2004 11:59:03 I ...

29. HQL: Compare dates    forum.hibernate.org

Hello! I need the "INNER JOIN FETCH" because the DueDate and the DueDateDetail are a master-detail joining. I know it is a little bit confusing because the d.duedate is a Set of dueDates and the dueDate is a Date. I found out that the questioning for the exact date (date, hours, minutes and seconds) is not the best way to compare ...

30. Use an elapsed time in HQL    forum.hibernate.org

I use a simple trick that works - I map my Date fields to columns of type "long" (we wrote a special user type for this). With this user type in place, I can do the math the same way I do it in Java. An added bonus is that our product works with databases with imprecise date/time types (e.g. MySQL ...

31. Date calculations in HQL    forum.hibernate.org

Hi, i want to make some date calculation for reporting purposes. Here is an example: Code: HQL-Query: select t.actualArrival-t.actualDeparture from TransportTask t I want to use this later to calculate average, sum etc. If this doesn't work in HQL, I'll have to do it in SQL. It would cost a lot of performance to do this stuff in java. Hibernate version: ...

32. Comparing Dates in HQL    forum.hibernate.org

Hibernate version:3.1 I want to compare dates in HQL, my model uses java.util.Date to map a oracle DATE column. Basically I need: -- Oracle SQL would be like this select * from a where trunc(a.dateAndTime) between trunc(?) and trunc(?) Hibernate does not allow me the use of "trunc()" because it maps the parameters as TIMESTAMP (when setting the preparedstatement parameter value) ...

33. using HQL to calculate Date difference    forum.hibernate.org

Hi guys Suppose there is a table in MySql database which has two fields of type Date, say startDate and endDate. Now, what's the exact HQL query to retrieve those records whose the difference between start and end date is e.g. 57 days. I have used the subtraction operator (-) but it doesn't work for days whose difference is more than ...

34. hql problem display only the first date returned    forum.hibernate.org

Hi everybody, I work with an Oracle Database. I have a problem with an hql querie witch should return a liste of date. It return the good number of rows but the date is always the same. It return the date of the first row. It's very weird because when I execute the oracle sql generated by hibernate, the result is ...

35. No data type for node: org.hibernate.hql.ast.tree.MethodNode    forum.hibernate.org

Hibernate Community View topic - No data type for node: org.hibernate.hql.ast.tree.MethodNode Login Register FAQ Search View unanswered posts | View active topics Board index Hibernate & Java Persistence Hibernate Users All times are UTC - 5 hours [ DST ] No data type for node: org.hibernate.hql.ast.tree.MethodNode Page 1 ...

36. null = null true HQL How?    forum.hibernate.org

I have a query that needs to also match nulls and I imagine there is a way to configure hibernate to do this automatically but have not found it. Basically I would like the following to also evaluate true for when both the column and java object are null. At the moment because null = null evaluates as false the query ...

37. date comparison in HQL    forum.hibernate.org

38. HQL date comparison issue    forum.hibernate.org

I suspect you're storing the time as well as the date in the orderDate field. In this case, when startDate and endDate are equal, you'll only select orders that match to the exact _second_. I'm guessing you want to select orders for a particular day. To do this, the _time_ of start date should be 00:00:00 i.e. midnight and the _time_ ...

39. Problem with Date HQL    forum.hibernate.org

Hi Im trying to figure out what's wrong with this query " from terminals te where te.creationDate between " + creationDateInit + " and " + creationDateEnd When I run this query i got an error org.springframework.orm.hibernate3.HibernateQueryException: unexpected token: Nov The query translates something like this te.creationDate between Mon Nov 26 00:00:00 GMT 2007 and Thu Nov 29 23:59:59 GMT 2007 ...

40. Dates comparison in HQL    forum.hibernate.org

41. How to compare date with HQL    forum.hibernate.org

Hello all, Hibernate version: 3 DB: MySQL5 I need to compare date entered by the user in format yyyy/mm/dd with the date in database. e.g MY HQL is select cust.customerName from customer cust where cust.expiryDate = '2009/02/21' This returns me 0 records, as in MySQL cust.expiryDate is '2009-02-21 14:27:02.0'. My problem is I do not know how to convert cust.expiryDate date ...

42. hhow to get date part using HQL    forum.hibernate.org

i would like to get the date part of value in the Date variable column from the database.. How can i write my hql to get ony the date part... ie to get "2008-04-30" from the value "2008-04-30 07:30:00".... i need it to compare with an incoming value of the format "2008-04-30" thanks in advance...

43. HQL date equality comparison: a solution    forum.hibernate.org

If you need to compare dates for equality in an HQL SELECT statement, but the hh:mm:ss portion of the database date makes equality fail, there is a simple and elegant solution, courtesy of Hibernate mapping 'formula' attribute. Here's an example for Oracle: The date property, 'myDateTime', is mapped as usual. The trick ...

45. No data type for node: org.hibernate.hql.ast.MethodNode    forum.hibernate.org

Hi i am trying to find Standard Deviation and i got this error for STDDEV... i tried STDDEV, STDEV, STD, STDEVP... notin worked:( any suggestions? java.lang.IllegalStateException: No data type for node: org.hibernate.hql.ast.MethodNode \-[METHOD_CALL] MethodNode: '(' +-[METHOD_NAME] IdentNode: 'STDEV' {originalText=STDEV} \-[EXPR_LIST] SqlNode: 'exprList' \-[DOT] DotNode: 'tournament0_.count' {propertyName=count,dereferenceType=4,propertyPath=count,path=ts.count,tableAlias=tournament0_,className=com.games24X7.persistence.dto.hibernate.TournamentStats,classAlias=ts} +-[ALIAS_REF] IdentNode: 'tournament0_.stat_id' {alias=ts, className=com.games24X7.persistence.dto.hibernate.TournamentStats, tableAlias=tournament0_} \-[WEIRD_IDENT] SqlNode: 'count' thankx aravind

47. HQL Date comparison    forum.hibernate.org

48. [ hql ] date    forum.hibernate.org

49. Date range in HQL    forum.hibernate.org

50. "No data type for node: org.hibernate.hql.ast.tree.MethodNo"    forum.hibernate.org

It is my first time running into this exception after having been using it for six year. I can't figure out the cause. Can someone give me a hand on this problem? The HQL: Code: select UserInfo(em.id,em.name,em.username,em.email,em.encoding,em.cityId) from Notification en left join en.pk.user em group by em.id,em.name,em.username,em.email,em.encoding,em.cityId Quote: 2009-08-31 12:03:11,281 ERROR [scheduler_Worker-1] JobRunShell.run(211) | Job DEFAULT.newEventNotificationJobDetail threw an unhandled Exception: java.lang.IllegalStateException: ...

51. how to pass current date to hql in hibernate    forums.oracle.com