Issue 12805

last login date for User wrongly set by mybatis

12805
Reporter: mdoering
Assignee: mdoering
Type: Bug
Summary: last login date for User wrongly set by mybatis
Priority: Major
Resolution: Fixed
Status: Closed
Created: 2013-02-22 12:08:49.641
Updated: 2013-09-02 13:46:32.527
Resolved: 2013-02-28 18:30:57.415
        
Description: Drupal stores the last user login (and other dates) simply as ints. It seems these are not the same as java since epoche longs and my current user sees a last login date of Wed Jan 31 14:47:00 CET 2018

Investigate if a custom mybatis type mapper is needed]]>
    


Author: mdoering@gbif.org
Created: 2013-02-28 12:50:22.084
Updated: 2013-02-28 12:50:22.084
        
when a user has never been logged in yet, mybatis actually throws an error cause it needs to convert a zero int:

{noformat}
HTTP ERROR 500

Problem accessing /user/downloads. Reason:


### Error querying database.  Cause: java.sql.SQLException: Value '0' can not be represented as java.sql.Timestamp
### The error may exist in org/gbif/user/mybatis/UserMapper.xml
### The error may involve org.gbif.user.mybatis.UserMapper.get-Inline
### The error occurred while setting parameters
### SQL: select  u.uid, u.name, u.mail, u.name as fullname, u.login, u.status, u.pass      from users u     where u.name = ?
### Cause: java.sql.SQLException: Value '0' can not be represented as java.sql.Timestamp
Caused by:

org.apache.ibatis.exceptions.PersistenceException:
### Error querying database.  Cause: java.sql.SQLException: Value '0' can not be represented as java.sql.Timestamp
### The error may exist in org/gbif/user/mybatis/UserMapper.xml
### The error may involve org.gbif.user.mybatis.UserMapper.get-Inline
### The error occurred while setting parameters
### SQL: select  u.uid, u.name, u.mail, u.name as fullname, u.login, u.status, u.pass      from users u     where u.name = ?
### Cause: java.sql.SQLException: Value '0' can not be represented as java.sql.Timestamp
	at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:23)
	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:104)
	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:95)
	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:59)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.apache.ibatis.session.SqlSessionManager$SqlSessionInterceptor.invoke(SqlSessionManager.java:282)
	at $Proxy45.selectOne(Unknown Source)
	at org.apache.ibatis.session.SqlSessionManager.selectOne(SqlSessionManager.java:151)
	at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:95)
	at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:40)
	at $Proxy47.get(Unknown Source)
	at org.gbif.user.mybatis.UserServiceImpl.get(UserServiceImpl.java:30)
	at org.gbif.portal.struts.DrupalSessionInterceptor.intercept(DrupalSessionInterceptor.java:47)
{noformat}

    


Author: mdoering@gbif.org
Created: 2013-02-28 18:30:57.443
Updated: 2013-02-28 18:30:57.443
        
php uses seconds since epoche while java uses milliseconds.
https://code.google.com/p/gbif-portal/source/detail?r=1433