JPA entity: get the hours,minutes and sec from Oracle DATE column

前端 未结 2 400
醉酒成梦
醉酒成梦 2021-01-06 07:40

I have problems to get the full DATE info from my Oracle DB (dd/mm/yyyy hh/mm/ss).

In the db level, in the column that I want to receive I set test values:



        
2条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-06 08:20

    By using the TIMESTAMP temporal type, you will get the date and the time part of the java date datatype but Oracle will make a column with the TIMESTAMP datatype. To overcome this issue if you want a DATE datatype, you can use the columnDefinition parameter of the column annotation such as:

    @Column(name = "MY_DATE_COLUMN", columnDefinition = "DATE")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateDetailed;
    

提交回复
热议问题