-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Error in TimestampType,AbstractSingleColumnStandardBasicType
PostPosted: Fri Dec 02, 2011 7:16 pm 
Newbie

Joined: Fri Dec 02, 2011 7:07 pm
Posts: 1
Hi,

I am using Spring Tool Suite with Java1-6, hibernate 3.5.5 and oracle 11g for my application. We decided to switch the database from Oracle to MySQL 5.5.18. I changed the database, changed the settings but when I try to compile my application, I get error in a class file that tries to create a UTC timestamp. Class is like this

Code:
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.Calendar;
import java.util.TimeZone;
import org.hibernate.type.TimestampType;

public class UtcTimestampType extends TimestampType {

    private static final TimeZone UTC = TimeZone.getTimeZone("UTC");

    @Override
    public Object get(ResultSet rs, String name) throws SQLException {
        return rs.getTimestamp(name, Calendar.getInstance(UTC));
    }

    @Override
    public void set(PreparedStatement st, Object value, int index) throws SQLException {
        Timestamp ts;
        if(value instanceof Timestamp) {
            ts = (Timestamp) value;
        } else {
            ts = new Timestamp(((java.util.Date) value).getTime());
        }
        st.setTimestamp(index, ts, Calendar.getInstance(UTC));
    }
}


When I try to compile it, I get couple errors at set method that
Error 1 : set(PreparedStatement, Object, int) of type UtcTimestampType has the same erasure as set(PreparedStatement, T, int) of type AbstractSingleColumnStandardBasicType<T> but does not override it.

Error 2 : The method set(PreparedStatement, Object, int) of type UtcTimestampType must override or implement a supertype method.

Timestamp class extends AbstractSingleColumnStandardBasicType. So, what is the mistake that I am doing here? I appreciate your help.

Thanks,
Jan.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.