Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7505785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:01:51+00:00 2026-05-29T22:01:51+00:00

I have an Oracle Date column in a db table, and fetching this field

  • 0

I have an Oracle Date column in a db table, and fetching this field by,

EntityManagerFactory emf = Persistence.createEntityManagerFactory("dbPU");
EntityManager em = emf.createEntityManager();

DateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy, HH:mm");
String query = "SELECT T.MDATE FROM MTABLE T";

List<Object[]> resultList = em.createNativeQuery(query).getResultList();
for (Object[] data : resultList) {
    System.out.println(dateFormat.format((java.util.Date) data[0]));
}

The “date” part of printed dates are correct but the “time” (ie. hour and second) parts are “00:00” for all of them. However when I checked this field in SQL Developer, the actual “time” parts are different than “00:00”. Where is the problem? Thanks in advance.

EDIT:
I am using,

Hibernate-Version: 3.2.5.ga
hibernate.dialect = org.hibernate.dialect.Oracle10gDialect
Oracle JDBC Driver version 10.2.0.1.0
Oracle Database 11g Express Edition Release 11.2.0.2.0
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T22:01:54+00:00Added an answer on May 29, 2026 at 10:01 pm

    Ok I finally resolved my problem. The cause was the adventure of Date (and Timestamp) datatype mappings of Oracle jdbc driver through its version timeline. In short, the problem was resolved by upgrading the ojdbc14.jar driver to ojdbc6.jar. For more info refer to What is going on with DATE and TIMESTAMP?

    In other words, the Oracle DATE type is mapped to Java as follows:
    ojdbc14.jar : DATE > java.sql.Date
    ojdbc6.jar : DATE > java.sql.Timestamp
    where java.sql.Date has no time parts.

    EDIT 17.03.2012 :
    If there is no chance to upgrade the driver due to other restrictions, then here is workaround for mapping Oracle DATE to java.sql.Timestamp in JPA with Hibernate:

    String queryStr = "SELECT T.MDATE FROM MTABLE T";
    Query query = em.createNativeQuery(queryStr);
    SQLQuery sqlQuery = (SQLQuery) ((HibernateQuery) query).getHibernateQuery();
    sqlQuery.addScalar("MDATE", Hibernate.TIMESTAMP);
    List<Object[]> resultList = query.getResultList();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table with a DATE column with time (as usual in Oracle
I have a table in an Oracle Database that has, among others, a DATE
I have a column in a table in which we are storing date in
I have a column in an Oracle DB table that is of type TIMESTAMP(6)
I have a Date type column in Oracle DB and it contains date and
I have a table in Oracle called quotes with two columns: date and value
I have an Oracle Date type to which I need to insert the current
I have a Oracle database and one of the fields is a date range
I have some code that uses the Oracle function add_months to increment a Date
I have a table that has a datetime column and I need to retrieve

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.