date « Data Type « JPA Q&A





1. How to read SQL Server 2008 date into Java using JPA    stackoverflow.com

I need to use java.util.Calendar in order for Axis2 webservice client to send/receive Date objects. So in my JPA model object I changed all java.sql.Date into java.util.Calendar. By using ...

2. Grails - findAll Posts Created Today by User    stackoverflow.com

I have a domain object.

class Post {
  User user
  String subject
  String body
  Date dateCreated
}
How do I go about this? Is straight GORM, HQL, or criteria the ...

3. using hibernate matchmode for Date    stackoverflow.com

I have a Date date= "26/12/2007" which i want to compare with my date in sql: "26/12/2007 12:00:00" like if i send date "26/12/2007" it should retrieve values against the date ...

4. Hibernate current date not working    stackoverflow.com

I have re-written this question to make it clear. I have an entity like this:

@Entity
@NamedQueries({
    @NamedQuery(
        name = "myObj.findCurrentUsingFunction", 
   ...

5. Handling Date in Hibernate    coderanch.com

6. Hibernate & Date    coderanch.com

I'm having a little bit of trouble figuring out why while querying records by a date isn't working correctly for me. I'm using Hibernate 3.0.5 and mysql 4.0.x. I have a method where I pass a date and internally it queries for between the date passed in and one day prior. public List getByDate(Date date) { Session s = HibernateUtil.getCurrentSession(); Calendar ...

7. Comapring dates in hibernate    coderanch.com

8. Comparing dates in hibernate    coderanch.com

9. comparing dates in hibernate    coderanch.com

Think of dates as having time stamps. Do if you just put a Day, Month, Year, there is still a time element in there, like Midnight. So anything done in the day, like 4PM, happens before Midnight. That is why. If you want to compare at the day level, you need to convert both sides to just the Day, Month, Year ...





10. Hibernate Date Issue    coderanch.com

Hi, I am using a Hibernate query for getting data from a table between two DATES. e.g., between 20/07/2007 to 31/08/2007. The problem is Hibernate is not taking the END date. Its taking date before the end date i.e., 30/08/2008. I am using AND.My Query is public List getChangeRequestDetailsForTerm( final List terms, final String officeValue, final String moduleValue, final String statusValue, ...

11. date operations in Hibernate    coderanch.com

Hi, I have a database table A which has among other columns, a column of type date(which is infact, full timestamp).. I want to query the table so that i get all the records for my current date. Ex. if the date column has values like "27th April ,10 PM", "28th April 5 AM", "28th April 11 AM", "29th April 12:30 ...

12. JPA 2.0 - good and up-to-date tutorial    coderanch.com

13. Date in Hibernate    coderanch.com

14. Date dd-Mon-yy is not returned correctly by Hibernate    coderanch.com

I am having an Oracle database which is storing date as 'dd-Mon-yy', example date is 14-JAN-97 03.25.03 PM. When I am getting this data from Hibernate I get date as- '14 January 2097'. How do I correct this? Here is debug output: DEBUG - returning '14 January 2097' as column: CREATION8_10_0_ However if I execute the SELECT query against database then ...

15. Date method always returns null    forum.hibernate.org

16. problems with trunc date    forum.hibernate.org

Hi all, I am trying to convert a sql query into hql, and in the original sql query, it has the where condition like "where cast(convert(varchar,created_on,112) as datetime) between ? and ?...." basically, the idea is to compare the date without considering the time differrence, e.g. in db created_on is 2010-06-30 12:12:12, and what I want is 2010-060-30 00:00:00. what I ...





17. Date dd-Mon-yy is not returned correctly by Hibernate    forum.hibernate.org

Hello, date(s) are not stored like that but as numbers, usually like "long", what you see is just a representation, Hibernate is not converting it to a string but it's converted at some point after that, implicitly by a call to toString() by the logger/sysout/debugger (wathever you used to see those strings) or explicitly by some conversion that you have applied ...

18. Unable to locate appropriate constructor on Date    forum.hibernate.org

I'm getting the following error message: Unable to locate appropriate constructor on class [java.util.Date] I'm running Hibernate 3.3.2 on Weblogic 10.3.2 and Oracle 10g. My SQL looks like this: SELECT new java.util.Date(MIN(o.eventTime)) FROM com.test.Event o where o.id > ? The eventTime column is a DATE. Is it possible to execute such a query? Thanks.

19. Date interval with null options    forum.hibernate.org

Hi there, I've a little problem I cannot solve properly. I've in a table, two date fields. The first one is called Valid_From and cannot be null. The second one is Valid_to and can be null. The idea is that if valid_to is null, there is no expiration date. I wish to only retreive valid rows from the database. The way ...

20. HIbernate Date Formats    forum.hibernate.org

Hi, Just a bit of background so I don't get bombarded with questions about WHY I want to do what I am doing. We have a Flex application communicating to a Java (GraniteDS) back end. Flex/AMF3 serializes Dates as just a number that represents UTC milliseconds from the epoch with NO time zone component so both Flex and Java assume local ...

21. @RevisionTimestamp can't use Date?    forum.hibernate.org

@RevisionEntity(MyRevisionListener.class) @Entity @Table(name = "KV_REV") public class Revision { @Id @GeneratedValue(strategy = GenerationType.AUTO) @RevisionNumber private Long id; @RevisionTimestamp @Temporal(TemporalType.TIMESTAMP) private Date auditingTimestamp; // more fields ...

22. JPA date literal syntax and Hibernate    forum.hibernate.org

23. problem with Date    forum.hibernate.org

Hi, I use java.util.Date for one property in my bean, I also set up "date" type in property in my mapping file. When I insert a row into db table, then load it by using its auto-generated id, I found the inserted date column value and the retrieved date column value are different. This is the reason why they are not ...

24. Comparing Dates    forum.hibernate.org

25. Current Date    forum.hibernate.org

I've been reading posts about the beta Hibernate having the ability to ask that but for now, I think you're limited to manually getting the java.sql.Connection object and doing your own JDBC call on it: Connection conn = sess.connection(); Statement stmt = conn.createStatement(); if ( stmt.execute("select CURRENT_DATE") ) { ResultSet rs = stmt.getResultSet(); rs.next(); System.out.println("The date is: " + rs.getString(1)); } ...

26. NamingStrategy Interface Out-of-Date    forum.hibernate.org

27. Cache up to date?    forum.hibernate.org

I have a pretty complex SQL query that returns results from a few different tables and performs a UNION etc. I execute this query using straight JDBC using session.connection(). I would like to be able to cache my results though. I know there is an Update Timestamp cache that Hibernate uses that has the timestamp of the latest change to any ...

28. How can i get the difference between two date    forum.hibernate.org

hi i am using hibernate and oracle for my application i need to make a query which return the difference between two date i am using java.util.Date for the date property. in details the problem is i need to know the age from the birth date. how can i write a quey which will give me the difference between the birth ...

29. Date comparison with literals    forum.hibernate.org

Hi there, I have searched the forum and checked the documentation but I cant seem to find how to compare dates with literals in hql. my database is mysql latest version my hbm.xml file stores the type as date select sbm from User as u inner join u.smsBoxMessages as sbm where u.id=1 and sbm.receipientMobileNumber like "%%" and sbm.date >= "2003-01-01" and ...

31. Best way to get the date literal?    forum.hibernate.org

Actually, I wasn't passing the string literal (I know not to do that!), I was just using the toString on java.sql.date because setDate or new Object[] { myDate } wasn't quite working, but I found it was something else. I'm actually getting back a date that is one month in advance on that calendar object. So I specify 2004/7/1 and I ...

32. Legacy date storage. How?    forum.hibernate.org

33. Handling Dates in a Legacy System    forum.hibernate.org

Newbie Joined: Mon Aug 09, 2004 4:28 am Posts: 18 Location: Australia Hibernate version: 2.1.5 Database: Ingres 2.6 I have started this as a new topic despite briefly raising it under the "Trimming fixed length char fields" topic ...... apologies for the two threads but I felt it warranted its own thread. I am trying to integrate to a legacy ingres ...

34. current date in a portable way    forum.hibernate.org

35. current date    forum.hibernate.org

36. java.date    forum.hibernate.org

As i remember if you make an instance of java.date it takes todays date as an argument, so if you create a new date and add it to the database you'll have todays date. Think it will do time as well but you might need another part of the api to do this as well.

37. Mutable Date's and dirty checking    forum.hibernate.org

for illustration, consider: Code: Date nowD = new Date(); Timestamp nowTS = new Timestamp( nowD.getTime() ); nowTS.setNanos(234); try { System.out.println(" Using Date.equals() : " ...

38. How to compare two Date in Hibernate?    forum.hibernate.org

39. Hibernate, XMLEncoder and Dates    forum.hibernate.org

Hi there, Found an intersting thing while I was playing with Hibernate & XMLEncoding... The need is to manage persistent objects in an application, and also to be able to serialize/deserialize them to/from XML. The direct idea is to use hibernate for persisting the objects, and XMLEncode them when you need it using the java.beans.XMLEncoder. This actually won't work ! The ...

40. Diference between two dates    forum.hibernate.org

41. I18N and Dates    forum.hibernate.org

My case is pretty basic but I'd like to know what you think about it. I developed an application for french people and the application is hosted in Canada. I'd like to be sure that dates are stored in the french timezone. At which level I should change the code ? MyClass { java.util.Date created; public MyClass { this.created = new ...

42. Proper way to handle date information    forum.hibernate.org

Hibernate version: 2.1 I'm attempting to sort entities using java.util.Date members, and implementing Comparable for use in "natural" sorting. I've run into a problem because I want to use plain old java.util.Date members in my domain model, but Hibernate constructs my domain objects with the java.sql.Timestamp subclass of java.util.Date. You would think there shouldn't be a problem with this, but Java's ...

43. java.io.InvalidClassException:Date & serialVersionUID    forum.hibernate.org

I am sure about of the code, you will understand what I am trying to achieve. At the end I have an exception: java.io.InvalidClassException: java.util.Date; local class incompatible: stream classdesc serialVersionUID = 7523895402267505689, local class serialVersionUID = 7523967970034938905 The table: CREATE TABLE `test` ( `PRODUCTID` char(12) NOT NULL default '', `LSTTRDTIM` datetime default NULL, `TIMESTAMP` bigint(20) unsigned NOT NULL default '0', ...

44. How to get current date?    forum.hibernate.org

Hi, I'm embarrassed to have to ask this, but can someone tell me how to query for the current date? I'm able to do this with a Hibernate Session using just straight JDBC code, but it's my understanding that not all databases have a "dual" table. So, my query of "select sysdate from dual" may not be portable. I've searched Google ...

45. Doubt with date    forum.hibernate.org

Hi I am using Sqlserver 2000 as my database with hibernate 2 I want to query a table for current date's data or between two dates .. my field data type is DateTime I just want to ignore time part for this particular report .. Can any onle help me out how to use dates with queries ... Thanks Vijesh

46. Doubt with date    forum.hibernate.org

47. How to compare 'Date' in Hibernate ?    forum.hibernate.org

Hi I was wondering if there is any particular way we need to handle 'Date' in order to search records for a given date. For time being I am just converting user entered date in the form to the format 'DD-MON-YY'. Does any one know any other way to do the date comparison ? Thanks Ron

48. Storing date-times in GMT -- Implications?    forum.hibernate.org

Well, I'm going to give the user type approach a try. Related question: I want to write an automated test that verifies that all Date and Calendar properties are mapped to one of the UTC-aware user types. I know I can use SessionFactory.getAllClassMetadata to get all of the entity classes and loop through their properties, but how can I find all ...

49. how to use setParamter() to set date ?    forum.hibernate.org

hi this is my query: delete from Accessed as acc where acc.userid=:user_id and acc.dat=:min_date how should i set the parameter "min_date" using the setParameter method ? mindate contains the date object to be set in the query. what change should i make to the below stated code to work correctly? query2.setParameter("min_date", mindate, Hibernate.DATE); this is only my second request to the ...

50. How to use Restrictions on Date Part ?    forum.hibernate.org

I have a somewhat similar question, and can't seem to find an answer on these forums. We have a table with a timestamp column, but would like to perform a query ignore the time part of that column, just the date. In SQL, something like: select * from orders where TRUNC(order_date) <= TO_DATE('07/16/2005', 'mm/dd/yyyy') to get all orders from today, regardless ...

51. Calculate difference between 2 dates    forum.hibernate.org

Need help with Hibernate? Read this first: http://www.hibernate.org/ForumMailingli ... AskForHelp [b]Hibernate version:[/b] Hibernate Synchronizer [b]Mapping documents:[/b] hibernate-mapping-2.0.dtd [b]Name and version of the database you are using:[/b] DB2 dear all, i need to calculate the date range between 2 date , my hql goes like this: select '2005-07-18 00:00:00.0'-AL.DtDocumentDate from tableA as AL where AL.SiRecordStatus = 1 and AL.DtDocumentDate <= '2005-07-18 00:00:00.0' ...

52. some bug in hibernate3.0.5's date    forum.hibernate.org

53. Hibernate 3.1 non beta date?    forum.hibernate.org

54. Date increased by one hour on retrieval    forum.hibernate.org

I was a bit incorrect in my original post. Here are the various representations of my date-time value: 1. The original string: "12/1/1935" 2. I parse this and create an instance of GregoriqanCalendar whcih has these values: year=1935, month=11, day=1, hour=0, minute=0, second=0 NOTE: The month is 0-based so this is correct. 3. I save the object containing this date into ...

55. Auto deduct 30minute for Date!    forum.hibernate.org

A quick google of SGT appears to be the Singapore time zone. One computer is set up with the timezone GMT offset and one is set up SGT as the time zone. If it's Windows, look in Control Panel / Date and Time. If it's unix, I wouldn't know. You will probably want to find a fix so that it works ...

56. Date Difference Calculation Conundrum    forum.hibernate.org

... class="ProcessLog" ...

57. automatically populate modified_date and creation_date    forum.hibernate.org

I've got a table with two columns I would like to be populated automatically via Hibernate: - modified_date - creation_date It probably goes without saying that I'd like to have the creation_date populated automatically only when the row is first inserted, and modified_date to be populated automatically every time the row is modified. Additionally, I would like the date to come ...

58. How to get max date using hibernate filters plzzzzzzz help    forum.hibernate.org

Need help with Hibernate? Read this first: http://www.hibernate.org/ForumMailingli ... AskForHelp hibernate version 3 ...

59. How does hibernate handle dates    forum.hibernate.org

Hi I am using hibernate and have my mapping correct with the db. I would like to perform a query using a date value. In what format must the date be my query looks as follows : " query.append("from com.directory.AuditEntry ae where ae.cretedOn = '2006-06-03 '"); must the value be equal to an object instead. It would also help if you ...

60. Date Comparison    forum.hibernate.org

I think that passing in a java.sql.Date instead of a java.util.Date should work, as SQL dates really are dates, not date and time. If that doesn't work, you can use HQL, which has the useful functions second(...), minute(...), hour(...), day(...), month(...), year(...) built in. Finally, you could be explicit and add two comparisons: >= startOfDate && <= endOfDate.

61. problem with obtaining the sum of dates    forum.hibernate.org

You can execute native SQL Queries using the createSQLQuery Method from the Criteria class. Its like the PreparedStatement using the ? as a placeholder. Pseudo code: SQLQuery sqlQuery = session.createSQLQuery("select ... from ... where x=? and y=?"); sqlQuery.setDate(0, ...); sqlQuery.setDate(1, ...); List result = sqlQuery.list(); The objects returned in the result depend on the Columns, iirc a single column is returned ...

62. Date operations    forum.hibernate.org

Hi, I try to write a HQL query having date operations like: from t_table where date_col1 > date_col2 + 8days At first I tried to change 8days in ms but the results were not those expected. Then I tried to create a Calendar instance initialized with 8days in ms (wich equals approx 08/01/1970) and to bind it to the query with ...

63. Does Hibernate has some Expiary Date!!!?    forum.hibernate.org

Author Message bormli Post subject: Does Hibernate has some Expiary Date!!!? Posted: Wed Sep 27, 2006 11:22 am Newbie Joined: Fri Aug 25, 2006 6:53 am Posts: 13 Hi, I have been using hibernate for over a year now. Ihave developed an applicationusing Hibernate 3.0. I have deployed this application on Tomcat and left it there running. It worked ...

64. Dates at Hibernate    forum.hibernate.org

Hibernate version:3.1 Mapping documents: false Name ...

65. how to add one year to the current date?    forum.hibernate.org

66. Problem Comparing Dates    forum.hibernate.org

I have a problem comparing dates with oracle, and i don't know how can I compare dates in the hql sentence. I Put the source code: Date iniDate = getIniDate(); //this obtains date in Spanish format: DD/MM/YYYY HH:mm:ss for example: 14/11/2006 10:00:00 Date endDate = getEndDate(); //this obtains date in the same format. For example: 15/11/2006 12:00:00 (In The database the ...

67. Hibernate Lucene integration : IndexReader out of date    forum.hibernate.org

Hi, I'm using Hibernate annotations with lucene in my program. This simple program persists an entity then delete it just after. The entity which is persisted is also indexed in a file using lucene. Here is the code : Code: public void run() { // create alarm Alarm alarm = new Alarm(); alarm.setName("new"); Alarm created = service.create(alarm); // get primary key ...

68. working with date    forum.hibernate.org

Hi, What is the best class when working with dates (no need for time)? There is java.util.Date, java.util.GregorianCalendar, java.sql.Date. It seems that java.util.Date and java.sql.Date is being depreciated. I am got a feeling that java.util.GregorianCalendar is slow? Is it true? Does it uses more resources compare to java.util.Date or java.sql.Date? Should I worry if I use java.util.GregorianCalendar Thanks james

69. Date Inconsistency    forum.hibernate.org

70. dates    forum.hibernate.org

hi, I'm kind of new to hibernate and I ran into a problem, I'm trying to generate statistics of a platform written in java and runs on an oracle DB what I'm trying to achieve is to get an overview from how many people have logged on to the system. Now... When I read the dates from the DB I get ...

71. How do I say lic_expiry_date is null in hibernet quer    forum.hibernate.org

public static List getActiveEfiLicenseTypeList(){ List efiLicenseTypeList = null; try { Query q = ...

72. hibernate issue please solve this about date persistance    forum.hibernate.org

Hi I am Please help me in this issue the problem is i cant able to insert the values into the child table here contact_method is parent table and contact_relation ship is child table The bellow is the query for creating the table the hibernate mapping is also provided so please... help in this issue The following are the create statements ...

73. problem with retrieving records usind date    forum.hibernate.org

74. All you should know about Date in Hibernate    forum.hibernate.org

Hello, The java.util.Date and the java.sql.Date within the hibernate context is one of the most often asked question. It is without a doubt the most confusing. I am creating this thread hoping to gather all in one place the answers to this question. Context: a model has member variables using a java.util.Date Date myDateOnly; //we only care about the Date not ...

75. How to do DAYS(Date)    forum.hibernate.org

I am using [b]Hibernate version: 2.1.6[/b] - yeah, I know, it's old, but that's the Corporate world for ya. I'm trying to evaluate the value of DAYS(date), date = a Date value to DB2 8.1 via Hibernate (in RAD 6), and am getting the following error: [b]Error: DB2 SQL error: SQLCODE: -104, SQLSTATE: 42601, SQLERRMC: );;< > = <> <= !< ...

76. difference (in days) between two dates...    forum.hibernate.org

77. Comparing dates with Restrictions.eq    forum.hibernate.org

this is a snippet from my logs Code: Hibernate: select this_.request_id as request1_19_0_, this_.date_created as date2_19_0_, this_.division as division19_0_, this_.product_group as product4_19_0_, this_.sale_reporting_code as sale5_19_0_, this_.product_type as product6_19_0_, this_.territory as territory19_0_, this_.presentation as presenta8_19_0_, this_.unitId as unitId19_0_, this_.code as code19_0_, this_.name as name19_0_, this_.unit_typeid as unit12_19_0_, this_.countryTypeId as country13_19_0_, this_.country as country19_0_, this_.collectionId as collect15_19_0_, this_.col_code as col16_19_0_, this_.col_name as col17_19_0_, ...

78. Date problem    forum.hibernate.org

here is a sample code from my dao that gets me a set of results between certain dates. Code: public List searchEvents(Date fromDate, Date toDate, String orderProperty, String orderDirection, Long first, Long max, String query){ Criteria criteria = getSession().createCriteria(EventEnt.class); ...

79. Is there a problem comparing dates/timestamps with Criterion    forum.hibernate.org

Author Message steppinrazor Post subject: Is there a problem comparing dates/timestamps with Criterion Posted: Fri Apr 11, 2008 12:21 am Beginner Joined: Thu Feb 28, 2008 11:53 am Posts: 23 Hibernate version: 3.2.4.sp1 Mapping documents: Using XML Name and version of the database I am using: Oracle XE/10G Stemming from my earlier post http://forum.hibernate.org/viewtopic.php?t=985706, I did some further testing ...

80. date    forum.hibernate.org

>hql query to find out the dates between the two dates Hi, From what I understand, this problem is a general date utility request. There is no place for any O/R mapping here. There is no specific table you want to query. It is more of a utility function which should return the list of dates between 2 dates. If what ...

81. problem with "zero day dates"    forum.hibernate.org

Hi all! I am connecting my app to a legacy mysql DB for reading only, all mappings work fine but I have the following problem: The db contains several columns with "zero day dates", e.g. 2007-06-00 and I want this to be reflected in my object as june 2007 Now it reads in as 2007-05-31 00:00:00.0 . I tried the LifeCycle ...

82. Date Interval Problem    forum.hibernate.org

Hey guys, Ive got some problem: I just want to select all hotels in my DBase, which are completely available between an date-interval. Ive got an hotel-instance an within these instance ive got another instance called availabilities (1:N). The relationship got the cardinality of 1:N because one hotel has many availability dates. so if i get an arrival date and a ...

83. date difference    forum.hibernate.org

Sorry if this solution was already asked but i searched and i did not find a proper answer. I have to create a simple query in sql but i ahve no clue how to make this in HQL : So i need to find all active customers in from a table that where not active in last 2 months,4 months,6 months. ...

85. Correlated subquerie with date conversion    forum.hibernate.org

Newbie Joined: Thu Jul 16, 2009 4:18 am Posts: 3 I'm trying to use the hibernate criteria api to achieve the following sql Code: select * from account_event ae1,event_type et1 where ae1.ACTUAL_EVENT_DT = (select Max(ae2.ACTUAL_EVENT_DT) from account_event ae2 ...

86. what is the NVL FOR DATE    forum.hibernate.org

87. Subtracting Dates    forum.hibernate.org