Example usage for org.hibernate.type StandardBasicTypes DOUBLE

List of usage examples for org.hibernate.type StandardBasicTypes DOUBLE

Introduction

In this page you can find the example usage for org.hibernate.type StandardBasicTypes DOUBLE.

Prototype

DoubleType DOUBLE

To view the source code for org.hibernate.type StandardBasicTypes DOUBLE.

Click Source Link

Document

The standard Hibernate type for mapping Double to JDBC java.sql.Types#DOUBLE DOUBLE .

Usage

From source file:br.ufpa.linc.xflow.data.database.XFlowMySqlDialect.java

License:Open Source License

public XFlowMySqlDialect() {
    super();/* w  w w  .j av a2s.  c o m*/
    registerFunction("variance", new StandardSQLFunction("variance", StandardBasicTypes.DOUBLE));
    registerFunction("stddev", new StandardSQLFunction("stddev", StandardBasicTypes.DOUBLE));
}

From source file:com.consult.app.dao.impl.CargoMessageDaoImpl.java

/**
 * Common Search cargo, used by 274 Version!
 * This supports multiple truck length/*from  w w  w . ja v a 2  s  . c  o m*/
 * 
 */
private List<Object> getMultipleTruckLengthSearch(SearchCargoRequest req, City endCity) {

    Long today = TimeUtils.getStartOfDay(System.currentTimeMillis());
    StringBuilder sb = new StringBuilder(String.format(Constant.CARGO_SEARCH_MULTIPLE_TRUCKLENGTH, today));

    if (Double.valueOf(req.getTruckLength()) >= 0) {
        sb.append(" and find_in_set(").append(req.getTruckLength()).append(",message.truck_length_set)");
    }

    if (req.getTruckType() >= 0) {
        sb.append(" and message.truck_type=").append(req.getTruckType());
    }

    if (req.getWeightRange() > 0) {
        sb.append(" and message.cargo_weight_range=").append(req.getWeightRange());
    }

    sb.append(" and (message.start=").append(req.getStart()).append(" or message.start_father=")
            .append(req.getStart()).append(" or message.start_grand=").append(req.getStart())
            .append(") and (message.end=").append(endCity.getId()).append(" or message.end_father=")
            .append(endCity.getId()).append(" or message.end_grand=").append(endCity.getId()).append(" or 0=")
            .append(endCity.getId()).append(")");

    sb.append(" and message.type>=? and message.type<4 order by message.update_time desc");

    Long triggerTime = req.getAfter();
    if (triggerTime.equals(Long.MAX_VALUE)) {
        triggerTime = System.currentTimeMillis();
    }
    CargoMessageInterceptor inter = new CargoMessageInterceptor();
    int count = req.getCount();
    //      for(int i = 0; i < Constant.SEARCH_TABLE_COUNT; i++) {
    Session session = null;
    try {
        //            Long messageId, int type,
        //            double weight, double capacity, int truckType,
        //            String contact, String telephone, int start, int end, 
        //            String description, long updateTime, double truckLength,
        //            String companyName, String companyAddress, String landlines, 
        //            String picture, int avatarAuthenticate, Long userId
        inter.setShardCriteria(System.currentTimeMillis());
        session = sessionFactory.openSession(inter);
        Query query = session.createSQLQuery(sb.toString()).addScalar("messageId", StandardBasicTypes.LONG)
                .addScalar("type", StandardBasicTypes.INTEGER).addScalar("weight", StandardBasicTypes.DOUBLE)
                .addScalar("capacity", StandardBasicTypes.DOUBLE)
                .addScalar("truckType", StandardBasicTypes.INTEGER)
                .addScalar("contact", StandardBasicTypes.STRING)
                .addScalar("telephone", StandardBasicTypes.STRING)
                .addScalar("start", StandardBasicTypes.INTEGER).addScalar("end", StandardBasicTypes.INTEGER)
                .addScalar("description", StandardBasicTypes.STRING)
                .addScalar("updateTime", StandardBasicTypes.LONG)
                .addScalar("truckLength", StandardBasicTypes.DOUBLE)
                .addScalar("companyName", StandardBasicTypes.STRING)
                .addScalar("companyAddress", StandardBasicTypes.STRING)
                .addScalar("landlines", StandardBasicTypes.STRING)
                .addScalar("picture", StandardBasicTypes.STRING)
                .addScalar("avatarAuthenticate", StandardBasicTypes.INTEGER)
                .addScalar("userId", StandardBasicTypes.LONG)
                .addScalar("licenseAuthenticate", StandardBasicTypes.INTEGER)
                .addScalar("cargoType", StandardBasicTypes.INTEGER)
                .addScalar("score", StandardBasicTypes.DOUBLE)
                .addScalar("orderCount", StandardBasicTypes.INTEGER)
                .addScalar("charges", StandardBasicTypes.INTEGER)
                .addScalar("messageCount", StandardBasicTypes.LONG)
                .addScalar("truckLengthSet", StandardBasicTypes.STRING).setResultTransformer(
                        Transformers.aliasToBean(com.consult.app.response.cargo.CargoMessageItem.class));
        query.setLong(0, req.getBefore());
        query.setLong(1, triggerTime);
        query.setInteger(2, Constant.TYPE_NORMAL);
        query.setFirstResult(0);
        query.setMaxResults(count);
        @SuppressWarnings("unchecked")
        List<Object> tmpList = query.list();
        //            if(tmpList != null && tmpList.size() > 0) {
        //               list.addAll(tmpList);
        //               if(tmpList.size() >= count) {
        //                  tx.commit();
        //                  return list;
        //               }
        //               count -= tmpList.size();
        ////               min = metaList.get(metaList.size() - 1).getUpdateTime();
        //            }
        //            if(inter.isFinishSearch(req.getBefore())) {
        //               tx.commit();
        //               return list;
        //            }
        //            triggerTime = inter.getTriggerTime();
        return tmpList;
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    } finally {
        if (session != null) {
            session.close();
            session = null;
        }
    }
}

From source file:com.consult.app.dao.impl.CargoMessageDaoImpl.java

/**
 * Search Nearby cargoMessages by multiple trucklength
 * @param req//w ww . j a  v a 2  s .co m
 * @param endCity
 * @return
 */
private List<Object> getNearbyMultipleTruckLengthSearch(SearchCargoRequest req, City endCity) {
    //      List<Object> list = new ArrayList<Object>();

    Long today = TimeUtils.getStartOfDay(System.currentTimeMillis());
    StringBuilder sb = new StringBuilder(
            String.format(Constant.NEARBY_CARGO_SEARCH_MULTIPLE_TRUCKLENGTH, today));

    if (Double.valueOf(req.getTruckLength()) >= 0) {
        sb.append(" and find_in_set(").append(req.getTruckLength()).append(",message.truck_length_set)");
    }

    if (req.getTruckType() >= 0) {
        sb.append(" and message.truck_type=").append(req.getTruckType());
    }

    if (req.getWeightRange() > 0) {
        sb.append(" and message.cargo_weight_range=").append(req.getWeightRange());
    }

    sb.append(" and city.id=").append(req.getStart()).append(
            " and (find_in_set(message.start, city.near_by) or find_in_set(message.start_father, city.near_by))")
            .append(" and (message.end=").append(endCity.getId()).append(" or message.end_father=")
            .append(endCity.getId()).append(" or message.end_grand=").append(endCity.getId()).append(" or 0=")
            .append(endCity.getId()).append(")");

    sb.append(" and message.type>=? and message.type<4 order by message.update_time desc");

    Long triggerTime = req.getAfter();
    if (triggerTime.equals(Long.MAX_VALUE)) {
        triggerTime = System.currentTimeMillis();
    }
    CargoMessageInterceptor inter = new CargoMessageInterceptor();
    int count = req.getCount();
    //      for(int i = 0; i < Constant.SEARCH_TABLE_COUNT; i++) {
    Session session = null;
    try {
        //            Long messageId, int type,
        //            double weight, double capacity, int truckType,
        //            String contact, String telephone, int start, int end, 
        //            String description, long updateTime, double truckLength,
        //            String companyName, String companyAddress, String landlines, 
        //            String picture, int avatarAuthenticate, Long userId
        inter.setShardCriteria(triggerTime);
        session = sessionReadFactory.openSession(inter);
        Query query = session.createSQLQuery(sb.toString()).addScalar("messageId", StandardBasicTypes.LONG)
                .addScalar("type", StandardBasicTypes.INTEGER).addScalar("weight", StandardBasicTypes.DOUBLE)
                .addScalar("capacity", StandardBasicTypes.DOUBLE)
                .addScalar("truckType", StandardBasicTypes.INTEGER)
                .addScalar("contact", StandardBasicTypes.STRING)
                .addScalar("telephone", StandardBasicTypes.STRING)
                .addScalar("start", StandardBasicTypes.INTEGER).addScalar("end", StandardBasicTypes.INTEGER)
                .addScalar("description", StandardBasicTypes.STRING)
                .addScalar("updateTime", StandardBasicTypes.LONG)
                .addScalar("truckLength", StandardBasicTypes.DOUBLE)
                .addScalar("companyName", StandardBasicTypes.STRING)
                .addScalar("companyAddress", StandardBasicTypes.STRING)
                .addScalar("landlines", StandardBasicTypes.STRING)
                .addScalar("picture", StandardBasicTypes.STRING)
                .addScalar("avatarAuthenticate", StandardBasicTypes.INTEGER)
                .addScalar("userId", StandardBasicTypes.LONG)
                .addScalar("licenseAuthenticate", StandardBasicTypes.INTEGER)
                .addScalar("cargoType", StandardBasicTypes.INTEGER)
                .addScalar("score", StandardBasicTypes.DOUBLE)
                .addScalar("orderCount", StandardBasicTypes.INTEGER)
                .addScalar("charges", StandardBasicTypes.INTEGER)
                .addScalar("messageCount", StandardBasicTypes.LONG)
                .addScalar("truckLengthSet", StandardBasicTypes.STRING).setResultTransformer(
                        Transformers.aliasToBean(com.consult.app.response.cargo.CargoMessageItem.class));
        query.setLong(0, req.getBefore());
        query.setLong(1, triggerTime);
        query.setInteger(2, Constant.TYPE_NORMAL);
        query.setFirstResult(0);
        query.setMaxResults(count);
        @SuppressWarnings("unchecked")
        List<Object> tmpList = query.list();
        //            if(tmpList != null && tmpList.size() > 0) {
        //               list.addAll(tmpList);
        //               if(tmpList.size() >= count) {
        //                  tx.commit();
        //                  return list;
        //               }
        //               count -= tmpList.size();
        ////               min = metaList.get(metaList.size() - 1).getUpdateTime();
        //            }
        //            if(inter.isFinishSearch(req.getBefore())) {
        //               tx.commit();
        //               return list;
        //            }
        //            triggerTime = inter.getTriggerTime();
        return tmpList;
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    } finally {
        if (session != null) {
            session.close();
            session = null;
        }
    }
    //      }
}

From source file:com.consult.app.dao.impl.CargoMessageDaoImpl.java

/**
 * Search Nearby cargoMessages/*from ww w . j  a  v  a  2  s .c o  m*/
 * Deprecated!
 * @param req
 * @param endCity
 * @return
 */
private List<Object> getNearbyMessage(SearchCargoRequest req, City endCity) {
    //      List<Object> list = new ArrayList<Object>();

    StringBuilder sb = new StringBuilder(Constant.NEARBY_CARGO_SEARCH);

    if (req.getTruckLengthRange() > 0) {
        sb.append(" and message.truck_length_range=").append(req.getTruckLengthRange());
    }

    if (req.getTruckType() >= 0) {
        sb.append(" and message.truck_type=").append(req.getTruckType());
    }

    if (req.getWeightRange() > 0) {
        sb.append(" and message.cargo_weight_range=").append(req.getWeightRange());
    }

    sb.append(" and city.id=").append(req.getStart()).append(
            " and (find_in_set(message.start, city.near_by) or find_in_set(message.start_father, city.near_by))")
            .append(" and (message.end=").append(endCity.getId()).append(" or message.end_father=")
            .append(endCity.getId()).append(" or message.end_grand=").append(endCity.getId()).append(" or 0=")
            .append(endCity.getId()).append(")");

    sb.append(" and message.type>=? and message.type<4 order by message.update_time desc");

    Long triggerTime = req.getAfter();
    if (triggerTime.equals(Long.MAX_VALUE)) {
        triggerTime = System.currentTimeMillis();
    }
    CargoMessageInterceptor inter = new CargoMessageInterceptor();
    int count = req.getCount();
    //      for(int i = 0; i < Constant.SEARCH_TABLE_COUNT; i++) {
    Session session = null;
    try {
        //            Long messageId, int type,
        //            double weight, double capacity, int truckType,
        //            String contact, String telephone, int start, int end, 
        //            String description, long updateTime, double truckLength,
        //            String companyName, String companyAddress, String landlines, 
        //            String picture, int avatarAuthenticate, Long userId
        inter.setShardCriteria(triggerTime);
        session = sessionFactory.openSession(inter);
        Query query = session.createSQLQuery(sb.toString()).addScalar("messageId", StandardBasicTypes.LONG)
                .addScalar("type", StandardBasicTypes.INTEGER).addScalar("weight", StandardBasicTypes.DOUBLE)
                .addScalar("capacity", StandardBasicTypes.DOUBLE)
                .addScalar("truckType", StandardBasicTypes.INTEGER)
                .addScalar("contact", StandardBasicTypes.STRING)
                .addScalar("telephone", StandardBasicTypes.STRING)
                .addScalar("start", StandardBasicTypes.INTEGER).addScalar("end", StandardBasicTypes.INTEGER)
                .addScalar("description", StandardBasicTypes.STRING)
                .addScalar("updateTime", StandardBasicTypes.LONG)
                .addScalar("truckLength", StandardBasicTypes.DOUBLE)
                .addScalar("companyName", StandardBasicTypes.STRING)
                .addScalar("companyAddress", StandardBasicTypes.STRING)
                .addScalar("landlines", StandardBasicTypes.STRING)
                .addScalar("picture", StandardBasicTypes.STRING)
                .addScalar("avatarAuthenticate", StandardBasicTypes.INTEGER)
                .addScalar("userId", StandardBasicTypes.LONG)
                .addScalar("licenseAuthenticate", StandardBasicTypes.INTEGER)
                .addScalar("cargoType", StandardBasicTypes.INTEGER)
                .addScalar("score", StandardBasicTypes.DOUBLE)
                .addScalar("orderCount", StandardBasicTypes.INTEGER)
                .addScalar("charges", StandardBasicTypes.INTEGER)
                .addScalar("messageCount", StandardBasicTypes.LONG)
                .addScalar("truckLengthSet", StandardBasicTypes.STRING).setResultTransformer(
                        Transformers.aliasToBean(com.consult.app.response.cargo.CargoMessageItem.class));
        query.setLong(0, req.getBefore());
        query.setLong(1, triggerTime);
        query.setInteger(2, Constant.TYPE_NORMAL);
        query.setFirstResult(0);
        query.setMaxResults(count);
        @SuppressWarnings("unchecked")
        List<Object> tmpList = query.list();
        //            if(tmpList != null && tmpList.size() > 0) {
        //               list.addAll(tmpList);
        //               if(tmpList.size() >= count) {
        //                  tx.commit();
        //                  return list;
        //               }
        //               count -= tmpList.size();
        ////               min = metaList.get(metaList.size() - 1).getUpdateTime();
        //            }
        //            if(inter.isFinishSearch(req.getBefore())) {
        //               tx.commit();
        //               return list;
        //            }
        //            triggerTime = inter.getTriggerTime();
        return tmpList;
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    } finally {
        if (session != null) {
            session.close();
            session = null;
        }
    }
    //      }
}

From source file:com.consult.app.dao.impl.UserDaoImpl.java

public List<Object> searchDriverList(SearchDriverRequest req) {
    /**// w ww  .  j av a 2 s . c  o m
     * 
     */
    long possitionTime = System.currentTimeMillis() - TimeUtils.DAY * 14;
    Query query = null;
    StringBuffer querysql = new StringBuffer("");
    String truckLengthCondition = req.getTruckLength() <= 0d ? "" : "and p.truck_length=:truckLength";
    String sqlTem = "(select u.user_id as userId,p.picture as picture,p.user_name as userName,u.telephone as telephone,p.truck_length as truckLength,p.truck_load as truckLoad,p.truck_type as truckType,p.number as number,u.is_authenticate as isAuthenticate,u.create_time as updateTime,p.order_count as orderCount,u.city as cityId,abs(u.city-:start) as sortFlag from users u, profiles p, %s sub, search_conditions sc where sub.user_id=u.user_id and u.user_id=p.user_id and p.user_type=1 and sub.search_id=sc.search_id and u.telephone>13000000000 "
            + truckLengthCondition
            + " and sub.push_subscribe=1 and u.push_subscribe=1 and u.type=1 and sub.type>0 and (sc.end=:end or sc.end=:endFather) and (sc.start=:start or sc.start=:startFather) and u.update_time>:before and u.update_time<:after and u.update_time>:possitionTime)";
    for (int i = 0; i < Constant.SHARD_TABLE_SUBSCRIBE.length; i++) {
        if (i == 0) {
            querysql.append("select t.* from (" + String.format(sqlTem, Constant.SHARD_TABLE_SUBSCRIBE[i])
                    + " union all ");
        } else if (i == Constant.SHARD_TABLE_SUBSCRIBE.length - 1) {
            querysql.append(String.format(sqlTem, Constant.SHARD_TABLE_SUBSCRIBE[i])
                    + ") t group by t.userId order by t.sortFlag asc,t.updateTime desc");//,t.orderCount desc
        } else {
            querysql.append(String.format(sqlTem, Constant.SHARD_TABLE_SUBSCRIBE[i]) + " union all ");
        }
    }

    query = sessionFactory.getCurrentSession().createSQLQuery(querysql.toString())
            .addScalar("userId", StandardBasicTypes.LONG).addScalar("picture", StandardBasicTypes.STRING)
            .addScalar("userName", StandardBasicTypes.STRING).addScalar("telephone", StandardBasicTypes.STRING)
            .addScalar("truckLength", StandardBasicTypes.DOUBLE)
            .addScalar("truckLoad", StandardBasicTypes.DOUBLE)
            .addScalar("truckType", StandardBasicTypes.INTEGER).addScalar("number", StandardBasicTypes.STRING)
            .addScalar("isAuthenticate", StandardBasicTypes.INTEGER)
            .addScalar("updateTime", StandardBasicTypes.LONG)
            .addScalar("orderCount", StandardBasicTypes.INTEGER).addScalar("cityId", StandardBasicTypes.INTEGER)
            .setResultTransformer(Transformers.aliasToBean(com.consult.app.response.truck.DriverInfo.class));
    if (req.getTruckLength() > 0) {
        query.setDouble("truckLength", req.getTruckLength());
    }
    query.setInteger("end", req.getEnd()).setInteger("endFather", req.getEndFather())
            .setInteger("start", req.getStart()).setInteger("startFather", req.getStartFather())
            .setLong("before", req.getBefore()).setLong("after", req.getAfter())
            .setLong("possitionTime", possitionTime);
    query.setMaxResults(req.getCount());
    @SuppressWarnings("unchecked")
    List<Object> all = query.list();
    return all;
}

From source file:com.consult.app.dao.impl.UserDaoImpl.java

public Object findDriverByTelephone(Long telephone) {
    Object obj = null;/*www . j  a  v  a  2  s  .  c om*/
    try {
        String sql = "select '1'as userType,u.user_id as userId,p.picture as picture,p.user_name as userName,u.telephone as telephone,p.truck_length as truckLength,p.truck_load as truckLoad,p.truck_type as truckType,p.number as number,u.is_authenticate as isAuthenticate from users u, profiles p where  u.user_id=p.user_id and p.user_type=1 and  u.telephone=? ";
        Query query = null;
        query = sessionFactory.getCurrentSession().createSQLQuery(sql)
                .addScalar("userType", StandardBasicTypes.INTEGER).addScalar("userId", StandardBasicTypes.LONG)
                .addScalar("picture", StandardBasicTypes.STRING)
                .addScalar("userName", StandardBasicTypes.STRING)
                .addScalar("telephone", StandardBasicTypes.STRING)
                .addScalar("truckLength", StandardBasicTypes.DOUBLE)
                .addScalar("truckLoad", StandardBasicTypes.DOUBLE)
                .addScalar("truckType", StandardBasicTypes.INTEGER)
                .addScalar("number", StandardBasicTypes.STRING)
                .addScalar("isAuthenticate", StandardBasicTypes.INTEGER)
                .setResultTransformer(Transformers.aliasToBean(com.consult.app.response.truck.DriverInfo.class))
                .setLong(0, telephone);
        obj = query.uniqueResult();
        if (obj == null) {
            sql = "select  '0' as userType, u.user_id as userId,'' as picture,u.user_name as userName,u.telephone as telephone,u.truck_length as truckLength,u.truck_load as truckLoad,u.truck_type as truckType,u.truck_number as number,0 as isAuthenticate from unregister_user u where   u.type=2 and  u.telephone=?";
            query = sessionFactory.getCurrentSession().createSQLQuery(sql)
                    .addScalar("userType", StandardBasicTypes.INTEGER)
                    .addScalar("userId", StandardBasicTypes.LONG)
                    .addScalar("picture", StandardBasicTypes.STRING)
                    .addScalar("userName", StandardBasicTypes.STRING)
                    .addScalar("telephone", StandardBasicTypes.STRING)
                    .addScalar("truckLength", StandardBasicTypes.DOUBLE)
                    .addScalar("truckLoad", StandardBasicTypes.DOUBLE)
                    .addScalar("truckType", StandardBasicTypes.INTEGER)
                    .addScalar("number", StandardBasicTypes.STRING)
                    .addScalar("isAuthenticate", StandardBasicTypes.INTEGER)
                    .setResultTransformer(
                            Transformers.aliasToBean(com.consult.app.response.truck.DriverInfo.class))
                    .setLong(0, telephone);
            obj = query.uniqueResult();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return obj;
}

From source file:com.consult.app.dao.impl.UserDaoImpl.java

public Object findDriverByUserId(Long id) {
    Object obj = null;/*from   www  .jav a  2 s  .com*/
    try {
        String sql = "select '1'as userType,u.user_id as userId,p.picture as picture,p.user_name as userName,u.telephone as telephone,p.truck_length as truckLength,p.truck_load as truckLoad,p.truck_type as truckType,p.number as number,u.is_authenticate as isAuthenticate from users u, profiles p where  u.user_id=p.user_id and p.user_type=1 and  u.user_id=? ";
        Query query = null;
        query = sessionFactory.getCurrentSession().createSQLQuery(sql)
                .addScalar("userType", StandardBasicTypes.INTEGER).addScalar("userId", StandardBasicTypes.LONG)
                .addScalar("picture", StandardBasicTypes.STRING)
                .addScalar("userName", StandardBasicTypes.STRING)
                .addScalar("telephone", StandardBasicTypes.STRING)
                .addScalar("truckLength", StandardBasicTypes.DOUBLE)
                .addScalar("truckLoad", StandardBasicTypes.DOUBLE)
                .addScalar("truckType", StandardBasicTypes.INTEGER)
                .addScalar("number", StandardBasicTypes.STRING)
                .addScalar("isAuthenticate", StandardBasicTypes.INTEGER)
                .setResultTransformer(Transformers.aliasToBean(com.consult.app.response.truck.DriverInfo.class))
                .setLong(0, id);
        obj = query.uniqueResult();
        if (obj == null) {
            sql = "select  '0' as userType, u.user_id as userId,'' as picture,u.user_name as userName,u.telephone as telephone,u.truck_length as truckLength,u.truck_load as truckLoad,u.truck_type as truckType,u.truck_number as number,0 as isAuthenticate from unregister_user u where   u.type=2 and  u.user_id=?";
            query = sessionFactory.getCurrentSession().createSQLQuery(sql)
                    .addScalar("userType", StandardBasicTypes.INTEGER)
                    .addScalar("userId", StandardBasicTypes.LONG)
                    .addScalar("picture", StandardBasicTypes.STRING)
                    .addScalar("userName", StandardBasicTypes.STRING)
                    .addScalar("telephone", StandardBasicTypes.STRING)
                    .addScalar("truckLength", StandardBasicTypes.DOUBLE)
                    .addScalar("truckLoad", StandardBasicTypes.DOUBLE)
                    .addScalar("truckType", StandardBasicTypes.INTEGER)
                    .addScalar("number", StandardBasicTypes.STRING)
                    .addScalar("isAuthenticate", StandardBasicTypes.INTEGER)
                    .setResultTransformer(
                            Transformers.aliasToBean(com.consult.app.response.truck.DriverInfo.class))
                    .setLong(0, id);
            obj = query.uniqueResult();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return obj;
}

From source file:com.liferay.portal.dao.orm.hibernate.DoubleType.java

License:Open Source License

public Type[] getPropertyTypes() {
    return new Type[] { StandardBasicTypes.DOUBLE };
}

From source file:com.liferay.portal.dao.orm.hibernate.DoubleType.java

License:Open Source License

public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner)
        throws SQLException {

    Double value = StandardBasicTypes.DOUBLE.nullSafeGet(rs, names[0], session);

    if (value == null) {
        return DEFAULT_VALUE;
    } else {//from w ww. ja v a 2  s  .  com
        return value;
    }
}

From source file:com.processpuzzle.fundamental_types.possiblevalue.domain.PossibleValueDefinitionTypeMapping.java

License:Open Source License

public Object nullSafeGet(ResultSet resultSet, String[] names, SessionImplementor session, Object owner)
        throws HibernateException, SQLException {
    String valueDefinitionClassDiscriminator = (String) StandardBasicTypes.STRING.nullSafeGet(resultSet,
            names[0], session);//  ww w  .  java 2 s  . c  o  m
    Double minAmount = (Double) StandardBasicTypes.DOUBLE.nullSafeGet(resultSet, names[1], session);
    String minUnitSymbol = (String) StandardBasicTypes.STRING.nullSafeGet(resultSet, names[2], session);
    Double maxAmount = (Double) StandardBasicTypes.DOUBLE.nullSafeGet(resultSet, names[3], session);
    String maxUnitSymbol = (String) StandardBasicTypes.STRING.nullSafeGet(resultSet, names[4], session);
    String possibleValues = (String) StandardBasicTypes.STRING.nullSafeGet(resultSet, names[5], session);

    ProcessPuzzleContext applicationContext = UserRequestManager.getInstance().getApplicationContext();
    MeasurementContext measurementContext = applicationContext.getMeasurementContext();
    if (valueDefinitionClassDiscriminator != null
            && valueDefinitionClassDiscriminator.endsWith("QuantityRange")) {
        if (minAmount != null && minUnitSymbol != null && maxAmount != null && maxUnitSymbol != null) {
            Quantity minValue = new Quantity(minAmount, measurementContext.findUnitBySymbol(minUnitSymbol));
            Quantity maxValue = new Quantity(maxAmount, measurementContext.findUnitBySymbol(maxUnitSymbol));

            return new QuantityRange(minValue, maxValue);
        }
    } else if (valueDefinitionClassDiscriminator != null
            && valueDefinitionClassDiscriminator.endsWith("QuantityEnumeration")) {
        return new QuantityEnumeration(possibleValues);
    } else if (valueDefinitionClassDiscriminator != null
            && valueDefinitionClassDiscriminator.endsWith("StringEnumeration")) {
        return new StringEnumeration(possibleValues);
    }
    return null;
}