public Boolean updateUser(String SID,long USER_ID){
  try {
    log.debug("updateUser User: " + USER_ID + " || "+ SID);
    String hql="select c from Sessiondata as c " + "where c.session_id LIKE :session_id";
    TypedQuery<Sessiondata> query=em.createQuery(hql,Sessiondata.class);
    query.setParameter("session_id",SID);
    List<Sessiondata> sessions=query.getResultList();
    Sessiondata sessiondata=null;
    if (sessions != null && sessions.size() > 0) {
      sessiondata=sessions.get(0);
    }
    if (sessiondata == null) {
      log.error("Could not find session to Update");
      return false;
    }
    log.debug("Found session to update: " + sessiondata.getSession_id() + " userId: "+ USER_ID);
    sessiondata.setRefresh_time(new Date());
    sessiondata.setUser_id(USER_ID);
    if (sessiondata.getId() == null) {
      em.persist(sessiondata);
    }
 else {
      if (!em.contains(sessiondata)) {
        em.merge(sessiondata);
      }
    }
    return true;
  }
 catch (  Exception ex2) {
    log.error("[updateUser]: ",ex2);
  }
  return null;
}

public Boolean updateUser ( String SID , long USER_ID ) { try { log . debug ( "updateUser User: " + USER_ID + " || " + SID ) ; String hql = "select c from Sessiondata as c " + "where c.session_id LIKE :session_id" ; TypedQuery < Sessiondata > query = em . createQuery ( hql , Sessiondata . class ) ; query . setParameter ( "session_id" , SID ) ; List < Sessiondata > sessions = query . getResultList ( ) ; Sessiondata sessiondata = null ; if ( sessions != null && sessions . size ( ) > 0 ) { sessiondata = sessions . get ( 0 ) ; } if ( sessiondata == null ) { log . error ( "Could not find session to Update" ) ; return false ; } log . debug ( "Found session to update: " + sessiondata . getSession_id ( ) + " userId: " + USER_ID ) ; sessiondata . setRefresh_time ( new Date ( ) ) ; sessiondata . setUser_id ( USER_ID ) ; if ( sessiondata . getId ( ) == null ) { em . persist ( sessiondata ) ; } else { if ( ! em . contains ( sessiondata ) ) { em . merge ( sessiondata ) ; } } return true ; } catch ( Exception ex2 ) { log . error ( "[updateUser]: " , ex2 ) ; } return null ; }
update the session of a user with a new user id this is needed to see if the session is loggedin
