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 for hours, and the FAQs, but I must be using bad search strings because I'm not finding this! I see lots of Hibernate code out there (including in the Hibernate documentation) that compares dates against "current date", so I'm thinking there's a way to get "current date" in a nice portable way using Hibernate.
Can anyone help me rewrite this in a happy, portable way? Thank you!
Hibernate version: 2.1.8
Code between sessionFactory.openSession() and session.close():
Code:
Session session = HibernateContext.getSession("java:/hibernate/SessionFactory");
Connection connection = session.connection();
Statement statement = connection.createStatement();
ResultSet rs = statement.executeQuery("select sysdate from dual");
rs.next();
this.timestamp = rs.getTimestamp(FIRST_COLUMN);
rs.close();
session.close();
Name and version of the database you are using:Oracle 9i 9.2.0.3