views:

58

answers:

1

I try to generate a trigger, in the trigger statement I have to set a column of type decimal(17,3) with the actual timestamp or the seconds of unix timestamp, but could not find a solution.

A: 

I found the solution

specify the datatype in the mysql table as decimal(17,3) hibernate map decimal to the java type BigDecimal, and the with a simple funtion:

public static Date bigDec2Date(BigDecimal tsp) {
    Calendar cal = Calendar.getInstance();
    cal.setTimeInMillis(tsp.longValue());
    return cal.getTime();
}
Alex