示例#1
0
  public int persistLocation(Location location) throws Exception {

    List<String> fields = new ArrayList<String>();
    fields.add("id"); // null should make it choose default, which uses sequence
    fields.add("user_id");
    fields.add("device_id");
    fields.add("location");
    fields.add("accuracy");
    fields.add("course");
    fields.add("speed");
    fields.add("time");

    MapSqlParameterSource params = new MapSqlParameterSource();
    params.addValue("id", location.getId());
    params.addValue("user_id", location.getUserid());
    params.addValue("device_id", location.getDeviceId());
    params.addValue("location", location.getLocation());
    params.addValue("accuracy", location.getAccuracy());
    params.addValue("course", location.getCourse());
    params.addValue("speed", location.getSpeed());
    params.addValue("time", location.getTime());

    QueryModel model = QueryManager.createQuery("location").insertInto(fields);

    int result = -1;
    try {
      result = this.template.update(model.toString(), params);
    } catch (Exception e) {

      throw new Exception("Unhandled exception while persisting Image entity: " + e.getMessage());
    }

    return result;
  }
示例#2
0
  public int persistImage(Image image) throws Exception {

    List<String> fields = new ArrayList<String>();
    fields.add("id"); // null should make it choose default, which uses sequence
    fields.add("location_id");
    fields.add("incident_id");
    fields.add("url");
    fields.add("fullpath");

    MapSqlParameterSource params = new MapSqlParameterSource();
    params.addValue("location_id", image.getLocation().getId());
    params.addValue("incident_id", image.getIncident().getIncidentid());
    params.addValue("url", image.getUrl());
    params.addValue("fullpath", image.getFullPath());

    QueryModel model = QueryManager.createQuery("image").insertInto(fields);

    int result = -1;
    try {
      result = this.template.update(model.toString(), params);
    } catch (Exception e) {

      throw new Exception("Unhandled exception while persisting Image entity: " + e.getMessage());
    }

    return result;
  }