My app is connected to a mysql database. I want to register some info about a product in a table including the date the row is added.
This is my table in mysql
Product:
Code:
ProductId primarykey int(4)
Comment varchar(100)
logDate dateTime
Hibernate mappping class
Product.hbm.xmlCode:
<hibernate-mapping>
<class name="db.Product" table="Product">
<id name="ProductID" type="long" column="ProductID">
<generator class="native"/>
</id>
<property name="comment" column="Comment" type="string"/>
<property name="logDate" column="logDate"/>
</class>
</hibernate-mapping>
1. question: what type should I use for the property logDate?
Code:
<property name="logDate" column="logDate"/>
Hibernate entity class
Product.javaCode:
public class Product {
private Long ProductID;
private String comment;
[b]private java.util.Date logDate;[/b]
Setter and getters...
2. question: What kind of
dateclass should I use?
Now I'm using java.util.Date, but nearly the whole class is deprecated!!!!
There is no point in using java.sql.Date either, because you got the same problem there....
In some parts of my code I want to seperate the
logTime from the
date. Should I use GregorianCalendar?
For me working with dates in java seems unnesessarily complicated.