问:
How to solve ClassCastException while posting my form values from jsp to controller on spring mvc 4
Am trying to update an entity.But am getting an ClassCastException while posting the values to controller. When i tried to debug its not coming inside the method. I will post my source code and POJO class here.

Driver Master POJO Class

```<code>@Id
@GeneratedValue
@Column(name = "ROW_ID")
private long row_id;

@NotEmpty
@Column(name = "DRIVER_NAME", nullable = false, length=50)
private String driverName;

@NotEmpty
@Column(name = "VEHICLE_NO", nullable = false, length=50)
private String vehicleNo;

@Column(name = "DRIVER_STATUS", nullable = false, length=50)
private int driverStatus;

@ManyToOne
@JoinColumn(name="DELZONE_ID")
private DeliveryZones deliveryZones;

//bi-directional many-to-one association to TaskMaster
@OneToMany(mappedBy="driverMaster")
private List<TaskMaster> taskMasters;
</code>```

Converter Class

```<code>public class DeliveryZoneToDriverConverter implements Converter<Object, DeliveryZones>{

static final Logger logger = LoggerFactory.getLogger(DeliveryZoneToDriverConverter.class);

@Autowired
DeliveryZoneService deliveryZoneService;

/**
 * Gets UserProfile by Id
 * @see org.springframework.core.convert.converter.Converter#convert(java.lang.Object)
 */
public DeliveryZones convert(Object element) {
    Integer id = Integer.parseInt((String)element);
    DeliveryZones profile= deliveryZoneService.findById(id);
    logger.info("Profile : {}",profile);
    return profile;
}
</code>```

Controller

```<code>@RequestMapping(value = { "/driver/newdriver" }, method = RequestMethod.POST)
public String saveDriver(@Valid DriverMaster driverMaster, BindingResult result,
        ModelMap model, final HttpServletRequest request) {

    if (result.hasErrors()) {
        return "driver/adddriver";
    }

    driverMaster.setDriverStatus(1);//to add active initially
    driverService.saveDriverMaster(driverMaster);

    model.addAttribute("success", "Driver " + driverMaster.getDriverName()
            + " Created successfully");
    model.addAttribute("loggedinuser", getPrincipal());
    // return "success";
    return "driver/adddriversuccess";
}
</code>```

Error am getting

```<code>2017-03-30 18:10:27,052 INFO  [stdout] (default task-33) Hibernate:
2017-03-30 18:10:27,053 INFO  [stdout] (default task-33)     select
2017-03-30 18:10:27,053 INFO  [stdout] (default task-33)         this_.ROW_ID as ROW_ID1_7_2_,
2017-03-30 18:10:27,054 INFO  [stdout] (default task-33)         this_.CITY_ID as CITY_ID3_7_2_,
2017-03-30 18:10:27,054 INFO  [stdout] (default task-33)         this_.DELZONE_NAME as DELZONE_2_7_2_,
2017-03-30 18:10:27,055 INFO  [stdout] (default task-33)         citymaster2_.ROW_ID as ROW_ID1_3_0_,
2017-03-30 18:10:27,055 INFO  [stdout] (default task-33)         citymaster2_.CITY_NAME as CITY_NAM2_3_0_,
2017-03-30 18:10:27,056 INFO  [stdout] (default task-33)         citymaster2_.state_id as state_id3_3_0_,
2017-03-30 18:10:27,056 INFO  [stdout] (default task-33)         statemaste3_.ROW_ID as ROW_ID1_17_1_,
2017-03-30 18:10:27,056 INFO  [stdout] (default task-33)         statemaste3_.country_id as country_3_17_1_,
2017-03-30 18:10:27,057 INFO  [stdout] (default task-33)         statemaste3_.STATE_NAME as STATE_NA2_17_1_
2017-03-30 18:10:27,057 INFO  [stdout] (default task-33)     from
2017-03-30 18:10:27,057 INFO  [stdout] (default task-33)         DELIVERY_ZONES this_
2017-03-30 18:10:27,058 INFO  [stdout] (default task-33)     left outer join
2017-03-30 18:10:27,058 INFO  [stdout] (default task-33)         CITY_MASTER citymaster2_
2017-03-30 18:10:27,058 INFO  [stdout] (default task-33)             on this_.CITY_ID=citymaster2_.ROW_ID
2017-03-30 18:10:27,058 INFO  [stdout] (default task-33)     left outer join
2017-03-30 18:10:27,059 INFO  [stdout] (default task-33)         STATE_MASTER statemaste3_
2017-03-30 18:10:27,059 INFO  [stdout] (default task-33)             on citymaster2_.state_id=statemaste3_.ROW_ID
2017-03-30 18:10:27,059 INFO  [stdout] (default task-33)     order by
2017-03-30 18:10:27,059 INFO  [stdout] (default task-33)         this_.DELZONE_NAME asc

2017-03-30 18:10:27,064 INFO  [stdout] (default task-33) Hibernate:
2017-03-30 18:10:27,064 INFO  [stdout] (default task-33)     select
2017-03-30 18:10:27,064 INFO  [stdout] (default task-33)         countrymas0_.ROW_ID as ROW_ID1_4_0_,
2017-03-30 18:10:27,065 INFO  [stdout] (default task-33)         countrymas0_.COUNTRY_NAME as COUNTRY_2_4_0_
2017-03-30 18:10:27,065 INFO  [stdout] (default task-33)     from
2017-03-30 18:10:27,065 INFO  [stdout] (default task-33)         COUNTRY_MASTER countrymas0_
2017-03-30 18:10:27,065 INFO  [stdout] (default task-33)     where
2017-03-30 18:10:27,065 INFO  [stdout] (default task-33)         countrymas0_.ROW_ID=?

2017-03-30 18:10:27,089 INFO  [com.aaratech.medtrack.dao.DriverDaoImpl] (default task-33) driverId : 5
2017-03-30 18:10:27,091 INFO  [stdout] (default task-33) Hibernate:
2017-03-30 18:10:27,091 INFO  [stdout] (default task-33)     select
2017-03-30 18:10:27,091 INFO  [stdout] (default task-33)         this_.ROW_ID as ROW_ID1_8_2_,
2017-03-30 18:10:27,092 INFO  [stdout] (default task-33)         this_.CREATED_BY as CREATED_2_8_2_,
2017-03-30 18:10:27,092 INFO  [stdout] (default task-33)         this_.CREATED_DATE as CREATED_3_8_2_,
2017-03-30 18:10:27,092 INFO  [stdout] (default task-33)         this_.DELZONE_ID as DELZONE13_8_2_,
2017-03-30 18:10:27,092 INFO  [stdout] (default task-33)         this_.DRIVER_NAME as DRIVER_N4_8_2_,
2017-03-30 18:10:27,092 INFO  [stdout] (default task-33)         this_.DRIVER_STATUS as DRIVER_S5_8_2_,
2017-03-30 18:10:27,093 INFO  [stdout] (default task-33)         this_.EMAIL_ID as EMAIL_ID6_8_2_,
2017-03-30 18:10:27,093 INFO  [stdout] (default task-33)         this_.IMEI_NO as IMEI_NO7_8_2_,
2017-03-30 18:10:27,093 INFO  [stdout] (default task-33)         this_.IS_ACTIVE as IS_ACTIV8_8_2_,
2017-03-30 18:10:27,093 INFO  [stdout] (default task-33)         this_.MODIFIED_BY as MODIFIED9_8_2_,
2017-03-30 18:10:27,093 INFO  [stdout] (default task-33)         this_.MODIFIED_DATE as MODIFIE10_8_2_,
2017-03-30 18:10:27,094 INFO  [stdout] (default task-33)         this_.PHONE as PHONE11_8_2_,
2017-03-30 18:10:27,094 INFO  [stdout] (default task-33)         this_.VEHICLE_NO as VEHICLE12_8_2_,
2017-03-30 18:10:27,094 INFO  [stdout] (default task-33)         deliveryzo2_.ROW_ID as ROW_ID1_7_0_,
2017-03-30 18:10:27,094 INFO  [stdout] (default task-33)         deliveryzo2_.CITY_ID as CITY_ID3_7_0_,
2017-03-30 18:10:27,094 INFO  [stdout] (default task-33)         deliveryzo2_.DELZONE_NAME as DELZONE_2_7_0_,
2017-03-30 18:10:27,095 INFO  [stdout] (default task-33)         citymaster3_.ROW_ID as ROW_ID1_3_1_,
2017-03-30 18:10:27,095 INFO  [stdout] (default task-33)         citymaster3_.CITY_NAME as CITY_NAM2_3_1_,
2017-03-30 18:10:27,095 INFO  [stdout] (default task-33)         citymaster3_.state_id as state_id3_3_1_
2017-03-30 18:10:27,095 INFO  [stdout] (default task-33)     from
2017-03-30 18:10:27,095 INFO  [stdout] (default task-33)         DRIVER_MASTER this_
2017-03-30 18:10:27,095 INFO  [stdout] (default task-33)     left outer join
2017-03-30 18:10:27,095 INFO  [stdout] (default task-33)         DELIVERY_ZONES deliveryzo2_
2017-03-30 18:10:27,095 INFO  [stdout] (default task-33)             on this_.DELZONE_ID=deliveryzo2_.ROW_ID
2017-03-30 18:10:27,096 INFO  [stdout] (default task-33)     left outer join
2017-03-30 18:10:27,096 INFO  [stdout] (default task-33)         CITY_MASTER citymaster3_
2017-03-30 18:10:27,096 INFO  [stdout] (default task-33)             on deliveryzo2_.CITY_ID=citymaster3_.ROW_ID
2017-03-30 18:10:27,096 INFO  [stdout] (default task-33)     where
2017-03-30 18:10:27,096 INFO  [stdout] (default task-33)         this_.ROW_ID=?

2017-03-30 18:10:27,100 INFO  [stdout] (default task-33) Hibernate:
2017-03-30 18:10:27,101 INFO  [stdout] (default task-33)     select
2017-03-30 18:10:27,101 INFO  [stdout] (default task-33)         statemaste0_.ROW_ID as ROW_ID1_17_0_,
2017-03-30 18:10:27,101 INFO  [stdout] (default task-33)         statemaste0_.country_id as country_3_17_0_,
2017-03-30 18:10:27,102 INFO  [stdout] (default task-33)         statemaste0_.STATE_NAME as STATE_NA2_17_0_,
2017-03-30 18:10:27,102 INFO  [stdout] (default task-33)         countrymas1_.ROW_ID as ROW_ID1_4_1_,
2017-03-30 18:10:27,102 INFO  [stdout] (default task-33)         countrymas1_.COUNTRY_NAME as COUNTRY_2_4_1_
2017-03-30 18:10:27,103 INFO  [stdout] (default task-33)     from
2017-03-30 18:10:27,103 INFO  [stdout] (default task-33)         STATE_MASTER statemaste0_
2017-03-30 18:10:27,103 INFO  [stdout] (default task-33)     left outer join
2017-03-30 18:10:27,103 INFO  [stdout] (default task-33)         COUNTRY_MASTER countrymas1_
2017-03-30 18:10:27,104 INFO  [stdout] (default task-33)             on statemaste0_.country_id=countrymas1_.ROW_ID
2017-03-30 18:10:27,104 INFO  [stdout] (default task-33)     where
2017-03-30 18:10:27,104 INFO  [stdout] (default task-33)         statemaste0_.ROW_ID=?

2017-03-30 18:10:27,154 INFO  [stdout] (default task-33) Hibernate:
2017-03-30 18:10:27,154 INFO  [stdout] (default task-33)     select
2017-03-30 18:10:27,154 INFO  [stdout] (default task-33)         deliveryzo0_.ROW_ID as ROW_ID1_7_0_,
2017-03-30 18:10:27,154 INFO  [stdout] (default task-33)         deliveryzo0_.CITY_ID as CITY_ID3_7_0_,
2017-03-30 18:10:27,154 INFO  [stdout] (default task-33)         deliveryzo0_.DELZONE_NAME as DELZONE_2_7_0_,
2017-03-30 18:10:27,155 INFO  [stdout] (default task-33)         citymaster1_.ROW_ID as ROW_ID1_3_1_,
2017-03-30 18:10:27,155 INFO  [stdout] (default task-33)         citymaster1_.CITY_NAME as CITY_NAM2_3_1_,
2017-03-30 18:10:27,155 INFO  [stdout] (default task-33)         citymaster1_.state_id as state_id3_3_1_,
2017-03-30 18:10:27,155 INFO  [stdout] (default task-33)         statemaste2_.ROW_ID as ROW_ID1_17_2_,
2017-03-30 18:10:27,155 INFO  [stdout] (default task-33)         statemaste2_.country_id as country_3_17_2_,
2017-03-30 18:10:27,155 INFO  [stdout] (default task-33)         statemaste2_.STATE_NAME as STATE_NA2_17_2_
2017-03-30 18:10:27,155 INFO  [stdout] (default task-33)     from
2017-03-30 18:10:27,155 INFO  [stdout] (default task-33)         DELIVERY_ZONES deliveryzo0_
2017-03-30 18:10:27,155 INFO  [stdout] (default task-33)     left outer join
2017-03-30 18:10:27,155 INFO  [stdout] (default task-33)         CITY_MASTER citymaster1_
2017-03-30 18:10:27,155 INFO  [stdout] (default task-33)             on deliveryzo0_.CITY_ID=citymaster1_.ROW_ID
2017-03-30 18:10:27,155 INFO  [stdout] (default task-33)     left outer join
2017-03-30 18:10:27,155 INFO  [stdout] (default task-33)         STATE_MASTER statemaste2_
2017-03-30 18:10:27,155 INFO  [stdout] (default task-33)             on citymaster1_.state_id=statemaste2_.ROW_ID
2017-03-30 18:10:27,155 INFO  [stdout] (default task-33)     where
2017-03-30 18:10:27,155 INFO  [stdout] (default task-33)         deliveryzo0_.ROW_ID=?

2017-03-30 18:10:27,162 INFO  [com.aaratech.medtrack.converter.DeliveryZoneToDriverConverter] (default task-33) Profile : null
2017-03-30 18:10:32,655 INFO  [stdout] (default task-47) Hibernate:
2017-03-30 18:10:32,656 INFO  [stdout] (default task-47)     select
2017-03-30 18:10:32,656 INFO  [stdout] (default task-47)         this_.ROW_ID as ROW_ID1_7_2_,
2017-03-30 18:10:32,656 INFO  [stdout] (default task-47)         this_.CITY_ID as CITY_ID3_7_2_,
2017-03-30 18:10:32,657 INFO  [stdout] (default task-47)         this_.DELZONE_NAME as DELZONE_2_7_2_,
2017-03-30 18:10:32,657 INFO  [stdout] (default task-47)         citymaster2_.ROW_ID as ROW_ID1_3_0_,
2017-03-30 18:10:32,657 INFO  [stdout] (default task-47)         citymaster2_.CITY_NAME as CITY_NAM2_3_0_,
2017-03-30 18:10:32,657 INFO  [stdout] (default task-47)         citymaster2_.state_id as state_id3_3_0_,
2017-03-30 18:10:32,657 INFO  [stdout] (default task-47)         statemaste3_.ROW_ID as ROW_ID1_17_1_,
2017-03-30 18:10:32,657 INFO  [stdout] (default task-47)         statemaste3_.country_id as country_3_17_1_,
2017-03-30 18:10:32,658 INFO  [stdout] (default task-47)         statemaste3_.STATE_NAME as STATE_NA2_17_1_
2017-03-30 18:10:32,658 INFO  [stdout] (default task-47)     from
2017-03-30 18:10:32,658 INFO  [stdout] (default task-47)         DELIVERY_ZONES this_
2017-03-30 18:10:32,658 INFO  [stdout] (default task-47)     left outer join
2017-03-30 18:10:32,658 INFO  [stdout] (default task-47)         CITY_MASTER citymaster2_
2017-03-30 18:10:32,658 INFO  [stdout] (default task-47)             on this_.CITY_ID=citymaster2_.ROW_ID
2017-03-30 18:10:32,658 INFO  [stdout] (default task-47)     left outer join
2017-03-30 18:10:32,658 INFO  [stdout] (default task-47)         STATE_MASTER statemaste3_
2017-03-30 18:10:32,658 INFO  [stdout] (default task-47)             on citymaster2_.state_id=statemaste3_.ROW_ID
2017-03-30 18:10:32,658 INFO  [stdout] (default task-47)     order by
2017-03-30 18:10:32,658 INFO  [stdout] (default task-47)         this_.DELZONE_NAME asc

2017-03-30 18:10:32,662 INFO  [stdout] (default task-47) Hibernate:
2017-03-30 18:10:32,662 INFO  [stdout] (default task-47)     select
2017-03-30 18:10:32,662 INFO  [stdout] (default task-47)         countrymas0_.ROW_ID as ROW_ID1_4_0_,
2017-03-30 18:10:32,662 INFO  [stdout] (default task-47)         countrymas0_.COUNTRY_NAME as COUNTRY_2_4_0_
2017-03-30 18:10:32,662 INFO  [stdout] (default task-47)     from
2017-03-30 18:10:32,662 INFO  [stdout] (default task-47)         COUNTRY_MASTER countrymas0_
2017-03-30 18:10:32,663 INFO  [stdout] (default task-47)     where
2017-03-30 18:10:32,663 INFO  [stdout] (default task-47)         countrymas0_.ROW_ID=?

2017-03-30 18:10:32,670 WARN  [org.springframework.validation.DataBinder] (default task-47) Skipping URI variable 'row_id' since the request contains a bind value with the same name.
2017-03-30 18:10:32,684 INFO  [stdout] (default task-47) Hibernate:
2017-03-30 18:10:32,684 INFO  [stdout] (default task-47)     select
2017-03-30 18:10:32,684 INFO  [stdout] (default task-47)         deliveryzo0_.ROW_ID as ROW_ID1_7_0_,
2017-03-30 18:10:32,685 INFO  [stdout] (default task-47)         deliveryzo0_.CITY_ID as CITY_ID3_7_0_,
2017-03-30 18:10:32,685 INFO  [stdout] (default task-47)         deliveryzo0_.DELZONE_NAME as DELZONE_2_7_0_,
2017-03-30 18:10:32,685 INFO  [stdout] (default task-47)         citymaster1_.ROW_ID as ROW_ID1_3_1_,
2017-03-30 18:10:32,685 INFO  [stdout] (default task-47)         citymaster1_.CITY_NAME as CITY_NAM2_3_1_,
2017-03-30 18:10:32,686 INFO  [stdout] (default task-47)         citymaster1_.state_id as state_id3_3_1_,
2017-03-30 18:10:32,686 INFO  [stdout] (default task-47)         statemaste2_.ROW_ID as ROW_ID1_17_2_,
2017-03-30 18:10:32,686 INFO  [stdout] (default task-47)         statemaste2_.country_id as country_3_17_2_,
2017-03-30 18:10:32,686 INFO  [stdout] (default task-47)         statemaste2_.STATE_NAME as STATE_NA2_17_2_
2017-03-30 18:10:32,686 INFO  [stdout] (default task-47)     from
2017-03-30 18:10:32,686 INFO  [stdout] (default task-47)         DELIVERY_ZONES deliveryzo0_
2017-03-30 18:10:32,687 INFO  [stdout] (default task-47)     left outer join
2017-03-30 18:10:32,687 INFO  [stdout] (default task-47)         CITY_MASTER citymaster1_
2017-03-30 18:10:32,687 INFO  [stdout] (default task-47)             on deliveryzo0_.CITY_ID=citymaster1_.ROW_ID
2017-03-30 18:10:32,687 INFO  [stdout] (default task-47)     left outer join
2017-03-30 18:10:32,687 INFO  [stdout] (default task-47)         STATE_MASTER statemaste2_
2017-03-30 18:10:32,687 INFO  [stdout] (default task-47)             on citymaster1_.state_id=statemaste2_.ROW_ID
2017-03-30 18:10:32,687 INFO  [stdout] (default task-47)     where
2017-03-30 18:10:32,687 INFO  [stdout] (default task-47)         deliveryzo0_.ROW_ID=?

2017-03-30 18:10:32,690 INFO  [stdout] (default task-47) Hibernate:
2017-03-30 18:10:32,690 INFO  [stdout] (default task-47)     select
2017-03-30 18:10:32,690 INFO  [stdout] (default task-47)         countrymas0_.ROW_ID as ROW_ID1_4_0_,
2017-03-30 18:10:32,690 INFO  [stdout] (default task-47)         countrymas0_.COUNTRY_NAME as COUNTRY_2_4_0_
2017-03-30 18:10:32,690 INFO  [stdout] (default task-47)     from
2017-03-30 18:10:32,690 INFO  [stdout] (default task-47)         COUNTRY_MASTER countrymas0_
2017-03-30 18:10:32,690 INFO  [stdout] (default task-47)     where
2017-03-30 18:10:32,691 INFO  [stdout] (default task-47)         countrymas0_.ROW_ID=?

2017-03-30 18:10:32,696 INFO  [com.aaratech.medtrack.converter.DeliveryZoneToDriverConverter] (default task-47) Profile : DeliveryZones [id=2]
2017-03-30 18:10:32,701 WARN  [org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver] (default task-47) Failed to bind request element: org.springframework.beans.TypeMismatchException: Failed to convert value of type [com.aaratech.medtrack.model.DriverMaster] to required type [com.aaratech.medtrack.model.DriverMaster]; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type [com.aaratech.medtrack.model.DriverMaster] to type [@javax.validation.Valid com.aaratech.medtrack.model.DriverMaster] for value 'DriverMaster [row_id=5]'; nested exception is java.lang.ClassCastException: com.aaratech.medtrack.model.DriverMaster cannot be cast to java.lang.String
</code>```

答:
Since the Error is

Failed to convert value of type Driver-Master to required type
  Driver-Master  nested exception is Conversion-Failed-Exception

Here Spring is trying to convert the object Driver-Master to String like it is done here.

```<code>public Delivery-Zones convert(Object element) {
    Integer id = Integer.parseInt((String)element);
}
</code>```

Please write your own converter method by overriding it.

Body:
Am trying to update an entity.But am getting an ClassCastException while posting the values to controller. When i tried to debug its not coming inside the method. I will post my source code and POJO class here.

Driver Master POJO Class

@Id
@GeneratedValue
@Column(name = "ROW_ID")
private long row_id;

@NotEmpty
@Column(name = "DRIVER_NAME", nullable = false, length=50)
private String driverName;

@NotEmpty
@Column(name = "VEHICLE_NO", nullable = false, length=50)
private String vehicleNo;

@Column(name = "DRIVER_STATUS", nullable = false, length=50)
private int driverStatus;

@ManyToOne
@JoinColumn(name="DELZONE_ID")
private DeliveryZones deliveryZones;

//bi-directional many-to-one association to TaskMaster
@OneToMany(mappedBy="driverMaster")
private List<TaskMaster> taskMasters;

Converter Class

public class DeliveryZoneToDriverConverter implements Converter<Object, DeliveryZones>{

static final Logger logger = LoggerFactory.getLogger(DeliveryZoneToDriverConverter.class);

@Autowired
DeliveryZoneService deliveryZoneService;

/**
 * Gets UserProfile by Id
 * @see org.springframework.core.convert.converter.Converter#convert(java.lang.Object)
 */
public DeliveryZones convert(Object element) {
    Integer id = Integer.parseInt((String)element);
    DeliveryZones profile= deliveryZoneService.findById(id);
    logger.info("Profile : {}",profile);
    return profile;
}

Controller

@RequestMapping(value = { "/driver/newdriver" }, method = RequestMethod.POST)
public String saveDriver(@Valid DriverMaster driverMaster, BindingResult result,
        ModelMap model, final HttpServletRequest request) {

    if (result.hasErrors()) {
        return "driver/adddriver";
    }

    driverMaster.setDriverStatus(1);//to add active initially
    driverService.saveDriverMaster(driverMaster);

    model.addAttribute("success", "Driver " + driverMaster.getDriverName()
            + " Created successfully");
    model.addAttribute("loggedinuser", getPrincipal());
    // return "success";
    return "driver/adddriversuccess";
}

Error am getting

2017-03-30 18:10:27,052 INFO  [stdout] (default task-33) Hibernate:
2017-03-30 18:10:27,053 INFO  [stdout] (default task-33)     select
2017-03-30 18:10:27,053 INFO  [stdout] (default task-33)         this_.ROW_ID as ROW_ID1_7_2_,
2017-03-30 18:10:27,054 INFO  [stdout] (default task-33)         this_.CITY_ID as CITY_ID3_7_2_,
2017-03-30 18:10:27,054 INFO  [stdout] (default task-33)         this_.DELZONE_NAME as DELZONE_2_7_2_,
2017-03-30 18:10:27,055 INFO  [stdout] (default task-33)         citymaster2_.ROW_ID as ROW_ID1_3_0_,
2017-03-30 18:10:27,055 INFO  [stdout] (default task-33)         citymaster2_.CITY_NAME as CITY_NAM2_3_0_,
2017-03-30 18:10:27,056 INFO  [stdout] (default task-33)         citymaster2_.state_id as state_id3_3_0_,
2017-03-30 18:10:27,056 INFO  [stdout] (default task-33)         statemaste3_.ROW_ID as ROW_ID1_17_1_,
2017-03-30 18:10:27,056 INFO  [stdout] (default task-33)         statemaste3_.country_id as country_3_17_1_,
2017-03-30 18:10:27,057 INFO  [stdout] (default task-33)         statemaste3_.STATE_NAME as STATE_NA2_17_1_
2017-03-30 18:10:27,057 INFO  [stdout] (default task-33)     from
2017-03-30 18:10:27,057 INFO  [stdout] (default task-33)         DELIVERY_ZONES this_
2017-03-30 18:10:27,058 INFO  [stdout] (default task-33)     left outer join
2017-03-30 18:10:27,058 INFO  [stdout] (default task-33)         CITY_MASTER citymaster2_
2017-03-30 18:10:27,058 INFO  [stdout] (default task-33)             on this_.CITY_ID=citymaster2_.ROW_ID
2017-03-30 18:10:27,058 INFO  [stdout] (default task-33)     left outer join
2017-03-30 18:10:27,059 INFO  [stdout] (default task-33)         STATE_MASTER statemaste3_
2017-03-30 18:10:27,059 INFO  [stdout] (default task-33)             on citymaster2_.state_id=statemaste3_.ROW_ID
2017-03-30 18:10:27,059 INFO  [stdout] (default task-33)     order by
2017-03-30 18:10:27,059 INFO  [stdout] (default task-33)         this_.DELZONE_NAME asc

2017-03-30 18:10:27,064 INFO  [stdout] (default task-33) Hibernate:
2017-03-30 18:10:27,064 INFO  [stdout] (default task-33)     select
2017-03-30 18:10:27,064 INFO  [stdout] (default task-33)         countrymas0_.ROW_ID as ROW_ID1_4_0_,
2017-03-30 18:10:27,065 INFO  [stdout] (default task-33)         countrymas0_.COUNTRY_NAME as COUNTRY_2_4_0_
2017-03-30 18:10:27,065 INFO  [stdout] (default task-33)     from
2017-03-30 18:10:27,065 INFO  [stdout] (default task-33)         COUNTRY_MASTER countrymas0_
2017-03-30 18:10:27,065 INFO  [stdout] (default task-33)     where
2017-03-30 18:10:27,065 INFO  [stdout] (default task-33)         countrymas0_.ROW_ID=?

2017-03-30 18:10:27,089 INFO  [com.aaratech.medtrack.dao.DriverDaoImpl] (default task-33) driverId : 5
2017-03-30 18:10:27,091 INFO  [stdout] (default task-33) Hibernate:
2017-03-30 18:10:27,091 INFO  [stdout] (default task-33)     select
2017-03-30 18:10:27,091 INFO  [stdout] (default task-33)         this_.ROW_ID as ROW_ID1_8_2_,
2017-03-30 18:10:27,092 INFO  [stdout] (default task-33)         this_.CREATED_BY as CREATED_2_8_2_,
2017-03-30 18:10:27,092 INFO  [stdout] (default task-33)         this_.CREATED_DATE as CREATED_3_8_2_,
2017-03-30 18:10:27,092 INFO  [stdout] (default task-33)         this_.DELZONE_ID as DELZONE13_8_2_,
2017-03-30 18:10:27,092 INFO  [stdout] (default task-33)         this_.DRIVER_NAME as DRIVER_N4_8_2_,
2017-03-30 18:10:27,092 INFO  [stdout] (default task-33)         this_.DRIVER_STATUS as DRIVER_S5_8_2_,
2017-03-30 18:10:27,093 INFO  [stdout] (default task-33)         this_.EMAIL_ID as EMAIL_ID6_8_2_,
2017-03-30 18:10:27,093 INFO  [stdout] (default task-33)         this_.IMEI_NO as IMEI_NO7_8_2_,
2017-03-30 18:10:27,093 INFO  [stdout] (default task-33)         this_.IS_ACTIVE as IS_ACTIV8_8_2_,
2017-03-30 18:10:27,093 INFO  [stdout] (default task-33)         this_.MODIFIED_BY as MODIFIED9_8_2_,
2017-03-30 18:10:27,093 INFO  [stdout] (default task-33)         this_.MODIFIED_DATE as MODIFIE10_8_2_,
2017-03-30 18:10:27,094 INFO  [stdout] (default task-33)         this_.PHONE as PHONE11_8_2_,
2017-03-30 18:10:27,094 INFO  [stdout] (default task-33)         this_.VEHICLE_NO as VEHICLE12_8_2_,
2017-03-30 18:10:27,094 INFO  [stdout] (default task-33)         deliveryzo2_.ROW_ID as ROW_ID1_7_0_,
2017-03-30 18:10:27,094 INFO  [stdout] (default task-33)         deliveryzo2_.CITY_ID as CITY_ID3_7_0_,
2017-03-30 18:10:27,094 INFO  [stdout] (default task-33)         deliveryzo2_.DELZONE_NAME as DELZONE_2_7_0_,
2017-03-30 18:10:27,095 INFO  [stdout] (default task-33)         citymaster3_.ROW_ID as ROW_ID1_3_1_,
2017-03-30 18:10:27,095 INFO  [stdout] (default task-33)         citymaster3_.CITY_NAME as CITY_NAM2_3_1_,
2017-03-30 18:10:27,095 INFO  [stdout] (default task-33)         citymaster3_.state_id as state_id3_3_1_
2017-03-30 18:10:27,095 INFO  [stdout] (default task-33)     from
2017-03-30 18:10:27,095 INFO  [stdout] (default task-33)         DRIVER_MASTER this_
2017-03-30 18:10:27,095 INFO  [stdout] (default task-33)     left outer join
2017-03-30 18:10:27,095 INFO  [stdout] (default task-33)         DELIVERY_ZONES deliveryzo2_
2017-03-30 18:10:27,095 INFO  [stdout] (default task-33)             on this_.DELZONE_ID=deliveryzo2_.ROW_ID
2017-03-30 18:10:27,096 INFO  [stdout] (default task-33)     left outer join
2017-03-30 18:10:27,096 INFO  [stdout] (default task-33)         CITY_MASTER citymaster3_
2017-03-30 18:10:27,096 INFO  [stdout] (default task-33)             on deliveryzo2_.CITY_ID=citymaster3_.ROW_ID
2017-03-30 18:10:27,096 INFO  [stdout] (default task-33)     where
2017-03-30 18:10:27,096 INFO  [stdout] (default task-33)         this_.ROW_ID=?

2017-03-30 18:10:27,100 INFO  [stdout] (default task-33) Hibernate:
2017-03-30 18:10:27,101 INFO  [stdout] (default task-33)     select
2017-03-30 18:10:27,101 INFO  [stdout] (default task-33)         statemaste0_.ROW_ID as ROW_ID1_17_0_,
2017-03-30 18:10:27,101 INFO  [stdout] (default task-33)         statemaste0_.country_id as country_3_17_0_,
2017-03-30 18:10:27,102 INFO  [stdout] (default task-33)         statemaste0_.STATE_NAME as STATE_NA2_17_0_,
2017-03-30 18:10:27,102 INFO  [stdout] (default task-33)         countrymas1_.ROW_ID as ROW_ID1_4_1_,
2017-03-30 18:10:27,102 INFO  [stdout] (default task-33)         countrymas1_.COUNTRY_NAME as COUNTRY_2_4_1_
2017-03-30 18:10:27,103 INFO  [stdout] (default task-33)     from
2017-03-30 18:10:27,103 INFO  [stdout] (default task-33)         STATE_MASTER statemaste0_
2017-03-30 18:10:27,103 INFO  [stdout] (default task-33)     left outer join
2017-03-30 18:10:27,103 INFO  [stdout] (default task-33)         COUNTRY_MASTER countrymas1_
2017-03-30 18:10:27,104 INFO  [stdout] (default task-33)             on statemaste0_.country_id=countrymas1_.ROW_ID
2017-03-30 18:10:27,104 INFO  [stdout] (default task-33)     where
2017-03-30 18:10:27,104 INFO  [stdout] (default task-33)         statemaste0_.ROW_ID=?

2017-03-30 18:10:27,154 INFO  [stdout] (default task-33) Hibernate:
2017-03-30 18:10:27,154 INFO  [stdout] (default task-33)     select
2017-03-30 18:10:27,154 INFO  [stdout] (default task-33)         deliveryzo0_.ROW_ID as ROW_ID1_7_0_,
2017-03-30 18:10:27,154 INFO  [stdout] (default task-33)         deliveryzo0_.CITY_ID as CITY_ID3_7_0_,
2017-03-30 18:10:27,154 INFO  [stdout] (default task-33)         deliveryzo0_.DELZONE_NAME as DELZONE_2_7_0_,
2017-03-30 18:10:27,155 INFO  [stdout] (default task-33)         citymaster1_.ROW_ID as ROW_ID1_3_1_,
2017-03-30 18:10:27,155 INFO  [stdout] (default task-33)         citymaster1_.CITY_NAME as CITY_NAM2_3_1_,
2017-03-30 18:10:27,155 INFO  [stdout] (default task-33)         citymaster1_.state_id as state_id3_3_1_,
2017-03-30 18:10:27,155 INFO  [stdout] (default task-33)         statemaste2_.ROW_ID as ROW_ID1_17_2_,
2017-03-30 18:10:27,155 INFO  [stdout] (default task-33)         statemaste2_.country_id as country_3_17_2_,
2017-03-30 18:10:27,155 INFO  [stdout] (default task-33)         statemaste2_.STATE_NAME as STATE_NA2_17_2_
2017-03-30 18:10:27,155 INFO  [stdout] (default task-33)     from
2017-03-30 18:10:27,155 INFO  [stdout] (default task-33)         DELIVERY_ZONES deliveryzo0_
2017-03-30 18:10:27,155 INFO  [stdout] (default task-33)     left outer join
2017-03-30 18:10:27,155 INFO  [stdout] (default task-33)         CITY_MASTER citymaster1_
2017-03-30 18:10:27,155 INFO  [stdout] (default task-33)             on deliveryzo0_.CITY_ID=citymaster1_.ROW_ID
2017-03-30 18:10:27,155 INFO  [stdout] (default task-33)     left outer join
2017-03-30 18:10:27,155 INFO  [stdout] (default task-33)         STATE_MASTER statemaste2_
2017-03-30 18:10:27,155 INFO  [stdout] (default task-33)             on citymaster1_.state_id=statemaste2_.ROW_ID
2017-03-30 18:10:27,155 INFO  [stdout] (default task-33)     where
2017-03-30 18:10:27,155 INFO  [stdout] (default task-33)         deliveryzo0_.ROW_ID=?

2017-03-30 18:10:27,162 INFO  [com.aaratech.medtrack.converter.DeliveryZoneToDriverConverter] (default task-33) Profile : null
2017-03-30 18:10:32,655 INFO  [stdout] (default task-47) Hibernate:
2017-03-30 18:10:32,656 INFO  [stdout] (default task-47)     select
2017-03-30 18:10:32,656 INFO  [stdout] (default task-47)         this_.ROW_ID as ROW_ID1_7_2_,
2017-03-30 18:10:32,656 INFO  [stdout] (default task-47)         this_.CITY_ID as CITY_ID3_7_2_,
2017-03-30 18:10:32,657 INFO  [stdout] (default task-47)         this_.DELZONE_NAME as DELZONE_2_7_2_,
2017-03-30 18:10:32,657 INFO  [stdout] (default task-47)         citymaster2_.ROW_ID as ROW_ID1_3_0_,
2017-03-30 18:10:32,657 INFO  [stdout] (default task-47)         citymaster2_.CITY_NAME as CITY_NAM2_3_0_,
2017-03-30 18:10:32,657 INFO  [stdout] (default task-47)         citymaster2_.state_id as state_id3_3_0_,
2017-03-30 18:10:32,657 INFO  [stdout] (default task-47)         statemaste3_.ROW_ID as ROW_ID1_17_1_,
2017-03-30 18:10:32,657 INFO  [stdout] (default task-47)         statemaste3_.country_id as country_3_17_1_,
2017-03-30 18:10:32,658 INFO  [stdout] (default task-47)         statemaste3_.STATE_NAME as STATE_NA2_17_1_
2017-03-30 18:10:32,658 INFO  [stdout] (default task-47)     from
2017-03-30 18:10:32,658 INFO  [stdout] (default task-47)         DELIVERY_ZONES this_
2017-03-30 18:10:32,658 INFO  [stdout] (default task-47)     left outer join
2017-03-30 18:10:32,658 INFO  [stdout] (default task-47)         CITY_MASTER citymaster2_
2017-03-30 18:10:32,658 INFO  [stdout] (default task-47)             on this_.CITY_ID=citymaster2_.ROW_ID
2017-03-30 18:10:32,658 INFO  [stdout] (default task-47)     left outer join
2017-03-30 18:10:32,658 INFO  [stdout] (default task-47)         STATE_MASTER statemaste3_
2017-03-30 18:10:32,658 INFO  [stdout] (default task-47)             on citymaster2_.state_id=statemaste3_.ROW_ID
2017-03-30 18:10:32,658 INFO  [stdout] (default task-47)     order by
2017-03-30 18:10:32,658 INFO  [stdout] (default task-47)         this_.DELZONE_NAME asc

2017-03-30 18:10:32,662 INFO  [stdout] (default task-47) Hibernate:
2017-03-30 18:10:32,662 INFO  [stdout] (default task-47)     select
2017-03-30 18:10:32,662 INFO  [stdout] (default task-47)         countrymas0_.ROW_ID as ROW_ID1_4_0_,
2017-03-30 18:10:32,662 INFO  [stdout] (default task-47)         countrymas0_.COUNTRY_NAME as COUNTRY_2_4_0_
2017-03-30 18:10:32,662 INFO  [stdout] (default task-47)     from
2017-03-30 18:10:32,662 INFO  [stdout] (default task-47)         COUNTRY_MASTER countrymas0_
2017-03-30 18:10:32,663 INFO  [stdout] (default task-47)     where
2017-03-30 18:10:32,663 INFO  [stdout] (default task-47)         countrymas0_.ROW_ID=?

2017-03-30 18:10:32,670 WARN  [org.springframework.validation.DataBinder] (default task-47) Skipping URI variable 'row_id' since the request contains a bind value with the same name.
2017-03-30 18:10:32,684 INFO  [stdout] (default task-47) Hibernate:
2017-03-30 18:10:32,684 INFO  [stdout] (default task-47)     select
2017-03-30 18:10:32,684 INFO  [stdout] (default task-47)         deliveryzo0_.ROW_ID as ROW_ID1_7_0_,
2017-03-30 18:10:32,685 INFO  [stdout] (default task-47)         deliveryzo0_.CITY_ID as CITY_ID3_7_0_,
2017-03-30 18:10:32,685 INFO  [stdout] (default task-47)         deliveryzo0_.DELZONE_NAME as DELZONE_2_7_0_,
2017-03-30 18:10:32,685 INFO  [stdout] (default task-47)         citymaster1_.ROW_ID as ROW_ID1_3_1_,
2017-03-30 18:10:32,685 INFO  [stdout] (default task-47)         citymaster1_.CITY_NAME as CITY_NAM2_3_1_,
2017-03-30 18:10:32,686 INFO  [stdout] (default task-47)         citymaster1_.state_id as state_id3_3_1_,
2017-03-30 18:10:32,686 INFO  [stdout] (default task-47)         statemaste2_.ROW_ID as ROW_ID1_17_2_,
2017-03-30 18:10:32,686 INFO  [stdout] (default task-47)         statemaste2_.country_id as country_3_17_2_,
2017-03-30 18:10:32,686 INFO  [stdout] (default task-47)         statemaste2_.STATE_NAME as STATE_NA2_17_2_
2017-03-30 18:10:32,686 INFO  [stdout] (default task-47)     from
2017-03-30 18:10:32,686 INFO  [stdout] (default task-47)         DELIVERY_ZONES deliveryzo0_
2017-03-30 18:10:32,687 INFO  [stdout] (default task-47)     left outer join
2017-03-30 18:10:32,687 INFO  [stdout] (default task-47)         CITY_MASTER citymaster1_
2017-03-30 18:10:32,687 INFO  [stdout] (default task-47)             on deliveryzo0_.CITY_ID=citymaster1_.ROW_ID
2017-03-30 18:10:32,687 INFO  [stdout] (default task-47)     left outer join
2017-03-30 18:10:32,687 INFO  [stdout] (default task-47)         STATE_MASTER statemaste2_
2017-03-30 18:10:32,687 INFO  [stdout] (default task-47)             on citymaster1_.state_id=statemaste2_.ROW_ID
2017-03-30 18:10:32,687 INFO  [stdout] (default task-47)     where
2017-03-30 18:10:32,687 INFO  [stdout] (default task-47)         deliveryzo0_.ROW_ID=?

2017-03-30 18:10:32,690 INFO  [stdout] (default task-47) Hibernate:
2017-03-30 18:10:32,690 INFO  [stdout] (default task-47)     select
2017-03-30 18:10:32,690 INFO  [stdout] (default task-47)         countrymas0_.ROW_ID as ROW_ID1_4_0_,
2017-03-30 18:10:32,690 INFO  [stdout] (default task-47)         countrymas0_.COUNTRY_NAME as COUNTRY_2_4_0_
2017-03-30 18:10:32,690 INFO  [stdout] (default task-47)     from
2017-03-30 18:10:32,690 INFO  [stdout] (default task-47)         COUNTRY_MASTER countrymas0_
2017-03-30 18:10:32,690 INFO  [stdout] (default task-47)     where
2017-03-30 18:10:32,691 INFO  [stdout] (default task-47)         countrymas0_.ROW_ID=?

2017-03-30 18:10:32,696 INFO  [com.aaratech.medtrack.converter.DeliveryZoneToDriverConverter] (default task-47) Profile : DeliveryZones [id=2]
2017-03-30 18:10:32,701 WARN  [org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver] (default task-47) Failed to bind request element: org.springframework.beans.TypeMismatchException: Failed to convert value of type [com.aaratech.medtrack.model.DriverMaster] to required type [com.aaratech.medtrack.model.DriverMaster]; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type [com.aaratech.medtrack.model.DriverMaster] to type [@javax.validation.Valid com.aaratech.medtrack.model.DriverMaster] for value 'DriverMaster [row_id=5]'; nested exception is java.lang.ClassCastException: com.aaratech.medtrack.model.DriverMaster cannot be cast to java.lang.String

Body:
Since the Error is

Failed to convert value of type Driver-Master to required type
  Driver-Master  nested exception is Conversion-Failed-Exception

Here Spring is trying to convert the object Driver-Master to String like it is done here.

public Delivery-Zones convert(Object element) {
    Integer id = Integer.parseInt((String)element);
}

Please write your own converter method by overriding it.


来源: stackexchange

问:
setTextSize doesn't work with AutofitTextView in Android
I'm using AutofitTextView and can't change text size on runtime. My XML:

```<code><me.grantland.widget.AutofitTextView
    android:id="@+id/header"
    android:text="Select Item"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:maxLines="1"
    android:textSize="85sp"
    autofit:minTextSize="16sp"
    autofit:sizeToFit="true"
    android:gravity="center"
    android:background="#fa0"
    android:textColor="@color/grey"
    />
</code>```

My code:

```<code> AutofitTextView header = (AutofitTextView) findViewById(R.id.header);
 header.setTextSize(TypedValue.COMPLEX_UNIT_SP, 25);
</code>```

Code works when I changed XML tags to TextView but I need it to work with AutofitTextView also. Any idea?

答:
You can use like

For fix size [No Auto]

```<code>header.setMinTextSize(TypedValue.COMPLEX_UNIT_SP,25);
header.setMaxTextSize(TypedValue.COMPLEX_UNIT_SP,25);
</code>```

For Auto [ Range will be between 16 to 25 ]

```<code>header.setMinTextSize(TypedValue.COMPLEX_UNIT_SP,16);
header.setMaxTextSize(TypedValue.COMPLEX_UNIT_SP,25);
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I'm using AutofitTextView and can't change text size on runtime. My XML:

<me.grantland.widget.AutofitTextView
    android:id="@+id/header"
    android:text="Select Item"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:maxLines="1"
    android:textSize="85sp"
    autofit:minTextSize="16sp"
    autofit:sizeToFit="true"
    android:gravity="center"
    android:background="#fa0"
    android:textColor="@color/grey"
    />

My code:

 AutofitTextView header = (AutofitTextView) findViewById(R.id.header);
 header.setTextSize(TypedValue.COMPLEX_UNIT_SP, 25);

Code works when I changed XML tags to TextView but I need it to work with AutofitTextView also. Any idea?

Body:
You can use like

For fix size [No Auto]

header.setMinTextSize(TypedValue.COMPLEX_UNIT_SP,25);
header.setMaxTextSize(TypedValue.COMPLEX_UNIT_SP,25);

For Auto [ Range will be between 16 to 25 ]

header.setMinTextSize(TypedValue.COMPLEX_UNIT_SP,16);
header.setMaxTextSize(TypedValue.COMPLEX_UNIT_SP,25);


问:
change panel heading colour when bootstrap accordion is open
When i click on accordion tab its colour has to change indicating the current tab is open. I am using ng2 bootstrap accordion

```<code>  <accordion-group #group1 [ngClass]="{'active':group1?.isOpen}" >
 <div accordion-heading > Div 1</div>
</code>```

and my css

```<code>.active[accordion-group] .panel-heading{
  background-color: black;
}
</code>```

but it didn't work. i referred the angularJS answer mentioned in the post Bootstrap 3 accordion styling on open/closed. can someone help me to fix it.

答:
just removed [accordion-group] and it worked perfectly.</p>

```<code>.active .panel-heading{
  background-color: black;
}
</code>```

Body:
When i click on accordion tab its colour has to change indicating the current tab is open. I am using ng2 bootstrap accordion

  <accordion-group #group1 [ngClass]="{'active':group1?.isOpen}" >

 Div 1

and my css

.active[accordion-group] .panel-heading{
  background-color: black;
}

but it didn't work. i referred the angularJS answer mentioned in the post Bootstrap 3 accordion styling on open/closed. can someone help me to fix it.

Body:
just removed [accordion-group] and it worked perfectly.

.active .panel-heading{
  background-color: black;
}


问:
UITextField hide placeholder text or bring cursor to front when clicked swift
Is there an up to date swift solution for making a UITextField placeholder disappear, or the cursor to be brought to the front as soon as a user clicks in the field, rather than when they start typing. I tried some of the solutions from older posts, and I tried the code below, but it doesn't seem to have the desired effect. Any help much appreciated.

```<code>class LogInViewController: UIViewController, UITextFieldDelegate {

@IBOutlet weak var userTextField: UITextField!
// the placeholder text is set in IB, with clear Button set to Appears while editing, and clear when editing begins button checked.

func textFieldDidBeginEditing(textField: UITextField) {
    userTextField.placeholder = nil
    passwordTextField.placeholder = nil
}
}
</code>```

This worked for me:

adding userTextField.delegate = self to view did load. // thanks I missed that

```<code> func textFieldDidBeginEditing(textField: UITextField) {

    if userTextField.isFirstResponder() == true {
        userTextField.placeholder = nil
    }
}
</code>```

答:
In Swift 3</p>

```<code>func textFieldDidBeginEditing(_ textField: UITextField) {
    if loginTextField.isFirstResponder == true {
        loginTextField.placeholder = ""
    }
}
</code>```

Body:
Is there an up to date swift solution for making a UITextField placeholder disappear, or the cursor to be brought to the front as soon as a user clicks in the field, rather than when they start typing. I tried some of the solutions from older posts, and I tried the code below, but it doesn't seem to have the desired effect. Any help much appreciated.

class LogInViewController: UIViewController, UITextFieldDelegate {

@IBOutlet weak var userTextField: UITextField!
// the placeholder text is set in IB, with clear Button set to Appears while editing, and clear when editing begins button checked.

func textFieldDidBeginEditing(textField: UITextField) {
    userTextField.placeholder = nil
    passwordTextField.placeholder = nil
}
}

This worked for me:

adding userTextField.delegate = self to view did load. // thanks I missed that

 func textFieldDidBeginEditing(textField: UITextField) {

    if userTextField.isFirstResponder() == true {
        userTextField.placeholder = nil
    }
}

Body:
In Swift 3

func textFieldDidBeginEditing(_ textField: UITextField) {
    if loginTextField.isFirstResponder == true {
        loginTextField.placeholder = ""
    }
}


问:
What numerical integration technique is used for integration of data sets performed in xmgrace?
From the information on topic - Integration of xmgrace,

... the item marked cumulative sum will construct a set composed of the current value of the integral at a given X. Sum only reports just the value on the next line. ...

I couldn't find information on the integration technique (Trapezoidal rule, Simpson's method ...) which thus motivates the question,

What numerical integration technique does xmgrace use to integrate the
  data sets chosen?

答:
After downloading the latest xmgrace (a.k.a. Grace) source code I first searched through all files for the word "integration".  I found a number of methods used for numerical integration. They all lead me to a function called trapint(), which is helpfully commented as shown:

```<code>/*
 * trapezoidal rule
 */
</code>```

It can be found in the file computils.c for anyone who wishes to investigate further.

Secondly, when I searched for "Simpson" I did not find anything.

According to this page, even MatLab does not have a built-in implementation of Simpson's method (I don't know how recent that page is, but I believe this is still true and couldn't find any other evidence of such a method).
Therefore, I would not expect xmgrace to have one either, since it is a much smaller program with only a few contributors.

Also, if Simpson's method had been implemented in xmgrace in addition to the Trapezoidal rule method, there would surely be an option in the Transformations > Integration menu, so that users could choose which method they wanted.

All this evidence strongly suggests to me that xmgrace uses just the Trapezoidal rule for numerical integration. I hope this answer satisfies you.

Body:
After downloading the latest xmgrace (a.k.a. Grace) source code I first searched through all files for the word "integration".  I found a number of methods used for numerical integration. They all lead me to a function called trapint(), which is helpfully commented as shown:

/*
 * trapezoidal rule
 */

It can be found in the file computils.c for anyone who wishes to investigate further.

Secondly, when I searched for "Simpson" I did not find anything.

According to this page, even MatLab does not have a built-in implementation of Simpson's method (I don't know how recent that page is, but I believe this is still true and couldn't find any other evidence of such a method).
Therefore, I would not expect xmgrace to have one either, since it is a much smaller program with only a few contributors.

Also, if Simpson's method had been implemented in xmgrace in addition to the Trapezoidal rule method, there would surely be an option in the Transformations > Integration menu, so that users could choose which method they wanted.

All this evidence strongly suggests to me that xmgrace uses just the Trapezoidal rule for numerical integration. I hope this answer satisfies you.


问:
Deck of cards, Segmentation fault: 11
I've been writing a program that populates a deck of cards. I'm using a makefile to build the executable but keep getting a segmentation fault when I execute. Can someone please take a look at the code below and point out where the error is coming from?

Thanks!

Card.h

```<code>#ifndef CARD_H
#define CARD_H
#include <iostream>

class Card
{
public:
        Card(char rankSet, char suitSet);
        Card();
private:
        char rank, suit;
};
#endif
</code>```

Card.cpp

```<code>#include "Card.h"

Card::Card()
{
        rank = 'A';
        suit = 'C';
}

Card::Card(char rankSet, char suitSet)
{
        rank = rankSet;
        suit = suitSet;
}
</code>```

Deck.h

```<code>#ifndef DECK_H
#define DECK_H
#include <iostream>
#include "Card.h"

class Deck
{
public:
        Deck();
private:
        Card *deckOfCards;
};
#endif
</code>```

Deck.cpp

```<code>#include "Deck.h"

Deck::Deck()
{
        char ranks[13] = {'A','2','3','4','5','6','7','8','9','T','J','Q','K'};
        char suits[4] = {'C','D','H','S'};

        deckOfCards = new Card[52];
        int k = 0;
        for(int i = 0; i<13; i++)
        {
                for(int j=0; j<4; i++)
                {
                        deckOfCards[k] = Card(ranks[i],suits[j]);
                        k++;
                }
        }
}
</code>```

Main.cpp

```<code>#include "Deck.h"

int main()
{
        Deck deck1;
        return 0;
}
</code>```

Makefile

```<code>#

CC = g++
CFLAGS  = -g -Wall -lm

#
default: Main

# To create the executable file count we need the object files

Main:  Main.o Card.o Deck.o
    $(CC) $(CFLAGS) -o Main main.o Card.o Deck.o

# To create the object file
Main.o:  main.cpp Deck.h Card.h
    $(CC) $(CFLAGS) -c main.cpp

# To create the object file
Deck.o:  Deck.cpp Deck.h Card.h
    $(CC) $(CFLAGS) -c Deck.cpp

# To create the object file
Card.o:  Card.cpp Card.h
    $(CC) $(CFLAGS) -c Card.cpp

clean:
    $(RM) Main *.o *~
</code>```

答: You increment i instead of j inside the for loop</p>

Title: Deck of cards, Segmentation fault: 11

Body:
I've been writing a program that populates a deck of cards. I'm using a makefile to build the executable but keep getting a segmentation fault when I execute. Can someone please take a look at the code below and point out where the error is coming from?

Thanks!

Card.h

#ifndef CARD_H
#define CARD_H
#include <iostream>

class Card
{
public:
        Card(char rankSet, char suitSet);
        Card();
private:
        char rank, suit;
};
#endif

Card.cpp

#include "Card.h"

Card::Card()
{
        rank = 'A';
        suit = 'C';
}

Card::Card(char rankSet, char suitSet)
{
        rank = rankSet;
        suit = suitSet;
}

Deck.h

#ifndef DECK_H
#define DECK_H
#include <iostream>
#include "Card.h"

class Deck
{
public:
        Deck();
private:
        Card *deckOfCards;
};
#endif

Deck.cpp

#include "Deck.h"

Deck::Deck()
{
        char ranks[13] = {'A','2','3','4','5','6','7','8','9','T','J','Q','K'};
        char suits[4] = {'C','D','H','S'};

        deckOfCards = new Card[52];
        int k = 0;
        for(int i = 0; i<13; i++)
        {
                for(int j=0; j<4; i++)
                {
                        deckOfCards[k] = Card(ranks[i],suits[j]);
                        k++;
                }
        }
}

Main.cpp

#include "Deck.h"

int main()
{
        Deck deck1;
        return 0;
}

Makefile

#

CC = g++
CFLAGS  = -g -Wall -lm

#
default: Main

# To create the executable file count we need the object files

Main:  Main.o Card.o Deck.o
    $(CC) $(CFLAGS) -o Main main.o Card.o Deck.o

# To create the object file
Main.o:  main.cpp Deck.h Card.h
    $(CC) $(CFLAGS) -c main.cpp

# To create the object file
Deck.o:  Deck.cpp Deck.h Card.h
    $(CC) $(CFLAGS) -c Deck.cpp

# To create the object file
Card.o:  Card.cpp Card.h
    $(CC) $(CFLAGS) -c Card.cpp

clean:
    $(RM) Main *.o *~


问:
Best OS to deploy a low latency Java application?
We have a low latency trading system (feed handlers, analytics, order entry) written in Java. It uses TCP and UDP extensively, it does not use Infiniband or other non-standard networking.

Can anyone comment on the tradeoffs of various OSes or OS configurations to deploy this system? While throughput is obviously important to keep up with modern price feeds, latency is our #1 priority.

Solaris seems like a natural candidate since they created Java; should I use Sparc or x64 processors?

I've heard good things about RHEL and SLERT, are those the right versions of Linux to use in our benchmarking.

Has anyone tested Windows against the above OSes? Or is it assumed to not keep up?

I'd like to leave the Java vs C++ debate for a different thread.

答:
The choice of operating system or configurable is completely redundant considering the availability of faster network fabrics.

Look at 10GigE with ToE NICs, or the faster solution of 4X QDR (40Gbs) InfiniBand but with IPoIB presenting a standard Ethernet interface and routing.

ContentLicense: CC BY-SA 2.5


问:
ReactJS: how to append a component to the App component in React
I am trying to append a "Item" component which consists of some array items, in the main "App" Component. But the component is getting replaced with the new array items instead of getting appended. Following is the code snippet:

```<code>//the App render function
render: function() {
    return (
        <div>
        {
            this.state.productDisplayed.map(function(product, i) {
                return (
                    <Item source = {product.url} prodId = {product.id}  key = {product.id} />
                )
            })
        }

        </div>
    )
}

//The Item render function
render: function(){
    return(
        <div className = "col-sm-4" >
            <img src = {this.props.source} width = "70%" className = "img-responsive"></img>
            <div>{this.props.prodId}
            </div>
        </div>
    )
}
</code>```

"ProductDisplayed" is an array which gets replaced by new items which are then displayed using a "for" loop.

How can i append the items as if I am adding some extra items to the main App component. I am trying to implement infinite scrolling.

答:
In order to append items to your app component, you need to append data to your productDisplayed state array

For this you can do something like

```<code>addItem=(item)=>{
     var productDisplayed=[...this.state.productDisplayed];
     productDisplayed.push(item);
     this.setState({productDisplayed});
}
</code>```

And you can call this function addItem on some event.

Body:
I am trying to append a "Item" component which consists of some array items, in the main "App" Component. But the component is getting replaced with the new array items instead of getting appended. Following is the code snippet:

//the App render function
render: function() {
    return (

        {
            this.state.productDisplayed.map(function(product, i) {
                return (
                    <Item source = {product.url} prodId = {product.id}  key = {product.id} />
                )
            })
        }

    )
}

//The Item render function
render: function(){
    return(

{this.props.prodId}

    )
}

"ProductDisplayed" is an array which gets replaced by new items which are then displayed using a "for" loop.

How can i append the items as if I am adding some extra items to the main App component. I am trying to implement infinite scrolling.

Body:
In order to append items to your app component, you need to append data to your productDisplayed state array

For this you can do something like

addItem=(item)=>{
     var productDisplayed=[...this.state.productDisplayed];
     productDisplayed.push(item);
     this.setState({productDisplayed});
}

And you can call this function addItem on some event.


答:
You have to use AutofitHelper to set textsize at runtime as follows :

```<code>// when resizing textview
header.setTextSize(TypedValue.COMPLEX_UNIT_SP, 25)
AutofitHelper autofitHelper = AutofitHelper.create(header);
autofitHelper.setTextSize(header.getTextSize());
</code>```

I hope it helps you

Title: setTextSize doesn't work with AutofitTextView in Android

Body:
You have to use AutofitHelper to set textsize at runtime as follows :

// when resizing textview
header.setTextSize(TypedValue.COMPLEX_UNIT_SP, 25)
AutofitHelper autofitHelper = AutofitHelper.create(header);
autofitHelper.setTextSize(header.getTextSize());

I hope it helps you


问:
Nesting and referencing xml file with JAXB
First of all, I am very new to xml world. I am facing problem to extract data from a cross-referenced xml file. Following is an example (modified):

```<code><?xml version="1.0" encoding="UTF-8"?>
<!-- Student info and students enrollment -->
<StudentList>
    <Student_info>
    <Student id = "1">
        <Name>Mike</Name>
        <Age>16</Age>
    </Student>
    <Student id="2">
        <Name>Matteo</Name>
        <Age>15</Age>
    </Student>
    <Student id="3">
        <Name>Matt</Name>
        <Age>17</Age>
    </Student>
    <Student id="4">
        <Name>Siri</Name>
        <Age>16</Age>
    </Student>
    <Student id="5">
       <Name>Sara</Name>
       <Age>15</Age>
       </Student>
    </Student_info>

    <Course_info>
       <Course id="PHY101">
            <Title>Physics Fundamentals></Title>
            <!-- Reference of the students enrolled in physics course -->
            <Student refid ="1"/>
            <Student refid = "2"/>
            <Student refid = "5"/>
        </Course>

    <Course id = "MATH101">
        <Title>Mathematics Basics</Title>
        <!-- Reference of the students enrolled in mathematics course -->
        <Student refid = "2"/>
        <Student refid = "3"/>
        <Student refid = "4"/>
    </Course>
    </Course_info>
</StudentList>
</code>```

Now, I would like to get the following output using java:

```<code>Course Title: Physics Fundamentals
Name of the enrolled students = Mike, Matteo and Sara
</code>```

And the same for the other course. How can I do that efficiently using java? My main question is to how to extract information from a cross-referenced element (such as Student refid ="1" in the example)?

An solution that I have found:

Firstly the xml file should be modified as follows:

```<code><?xml version="1.0" encoding="UTF-8"?>
<!-- Student info and students enrollment -->
<StudentList>
    <Student_info>
    <Student id = "1">
        <Name>Mike</Name>
        <Age>16</Age>
    </Student>
    <Student id="2">
        <Name>Matteo</Name>
        <Age>15</Age>
    </Student>
    <Student id="3">
        <Name>Matt</Name>
        <Age>17</Age>
    </Student>
    <Student id="4">
        <Name>Siri</Name>
        <Age>16</Age>
    </Student>
    <Student id="5">
       <Name>Sara</Name>
       <Age>15</Age>
       </Student>
    </Student_info>

    <Course_info>
       <Course id="PHY101">
            <Title>Physics Fundamentals></Title>
            <!-- Reference of the students enrolled in physics course -->
            <!-- Make change here -->
            <Student>1</Student>
            <Student>2</Student>
            <Student>5</Student>
        </Course>

    <Course id = "MATH101">
        <Title>Mathematics Basics</Title>
        <!-- Reference of the students enrolled in mathematics course -->
        **<!-- Make change here -->**
        <Student>3</Student>
        <Student>4</Student>
    </Course>
    </Course_info>
</StudentList>
</code>```

Now, Student class:

```<code>import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlID;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;

@XmlRootElement(name = "Student")
@XmlAccessorType(XmlAccessType.FIELD)
public class Student
{

    private String Name;
    private int Age;
    @XmlAttribute(name = "id")
    @XmlID
    private String id;

    public String getName()
    {
        return Name;
    }

    public void setName(String name)
    {
        Name = name;
    }

    public int getAge()
    {
        return Age;
    }

    public void setAge(int age)
    {
        Age = age;
    }

    public String getId()
    {
        return id;
    }

    public void setId(String id)
    {
        this.id = id;
    }
}
</code>```

Course class:

```<code>import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlIDREF;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;

    @XmlRootElement(name = "Course")
    class Course
    {
        @XmlAttribute(name = "cid")
        String id;
        @XmlElement(name = "Title")
        String Title;

        @XmlElement(name="Student")
        @XmlIDREF
        List<Student> student;

        Course(){
            student = new ArrayList<Student>();
        }

        String getID()
        {
            return id;
        }

        String getTitle()
        {
            return Title;
        }

        void setID(String id)
        {
            this.id = id;
        }

        void setTitle(String title)
        {
            this.Title = title;
        }

        List<Student> getStudent()
        {
            return student;
        }

        void setStudents(List<Student> student)
        {
            this.student = student;
        }

 }
</code>```

StudentList class:

```<code>import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name = "StudentList")
public class StudentList
{

    private List<Student> Student_info;
    private List<Course> Course_info;

    @XmlElement(name = "Student")
    public List<Student> getStudent_info()
    {
        return Student_info;
    }

    public void setStudent_info(List<Student> Student_info)
    {
        this.Student_info = Student_info;
    }

    @XmlElement(name = "Course")
    public List<Course> getCourse_Info()
    {
        return Course_info;
    }

    public void setCourse_Info(List<Course> Course_info)
    {
        this.Course_info = Course_info;
    }
}
</code>```

TextXml class:

```<code>import java.io.File;
import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;

    public class TextXml {
          public static void main(String[] args)
            {

                try
                {

                    JAXBContext jc = JAXBContext.newInstance(StudentList.class);
                    Unmarshaller unmarshaller = jc.createUnmarshaller();

                    File xml = new File("NewFile.xml");
                    StudentList studentlist = (StudentList) unmarshaller.unmarshal(xml);

                    for (Course course: studentlist.getCourse_Info()){
                        System.out.println("Course Title: "+course.getTitle());
                        for(Student std: course.getStudent()){
                            System.out.print(std.getName()+" ");
                        }
                        System.out.println();
                    }

                }
                catch (JAXBException e)
                {
                    e.printStackTrace();
                }

            }
        }
</code>```

Thanks.

答:
```<code>    <?xml version="1.0" encoding="UTF-8"?>
<!-- Student info and students enrollment -->
<StudentList>
    <Student id = "1">
        <Name>Mike</Name>
        <Age>16</Age>
    </Student>
    <Student id="2">
        <Name>Matteo</Name>
        <Age>15</Age>
    </Student>
    <Student id="3">
        <Name>Matt</Name>
        <Age>17</Age>
    </Student>
    <Student id="4">
        <Name>Siri</Name>
        <Age>16</Age>
    </Student>
    <Student id="5">
       <Name>Sara</Name>
       <Age>15</Age>
     </Student>
     <Course id="PHY101">
        <Title>Physics Fundamentals</Title>
        <!-- Reference of the students enrolled in physics course -->
            <Student refid ="1"/>
            <Student refid = "2"/>
     </Course>
     <Course id = "MATH101">
        <Title>Mathematics Basics</Title>
        <!-- Reference of the students enrolled in mathematics course -->
            <Student refid = "2"/>
            <Student refid = "3"/>
            <Student refid = "4"/>
      </Course>
  </StudentList>
</code>```

```<code> package test;

    import javax.xml.bind.annotation.XmlAccessType;
    import javax.xml.bind.annotation.XmlAccessorType;
    import javax.xml.bind.annotation.XmlAttribute;
    import javax.xml.bind.annotation.XmlRootElement;

    @XmlRootElement(name = "Student")
    @XmlAccessorType(XmlAccessType.FIELD)
    public class Student
    {

        private String Name;
        private int Age;
        @XmlAttribute(name = "id")
        private int id;
        @XmlAttribute(name = "refid")
        private int refid;

        public String getName()
        {
            return Name;
        }

        public void setName(String name)
        {
            Name = name;
        }

        public int getAge()
        {
            return Age;
        }

        public void setAge(int age)
        {
            Age = age;
        }

        public int getId()
        {
            return id;
        }

        public void setId(int id)
        {
            this.id = id;
        }

        public int getRefid()
        {
            return refid;
        }

        public void setRefid(int refid)
        {
            this.refid = refid;
        }

    }
</code>```

```<code>     package test;

    import java.util.List;
    import javax.xml.bind.annotation.XmlAccessType;
    import javax.xml.bind.annotation.XmlAccessorType;
    import javax.xml.bind.annotation.XmlAttribute;
    import javax.xml.bind.annotation.XmlElement;
    import javax.xml.bind.annotation.XmlRootElement;

    @XmlRootElement(name = "Course")
    @XmlAccessorType(XmlAccessType.FIELD)
    public class Course
    {
        @XmlAttribute(name = "id")
        private String id;
        private String Title;
        @XmlElement(name = "Student")
        private List<Student> Students = null;

        public String getID()
        {
            return id;
        }

        public String getTitle()
        {
            return Title;
        }

        public void setID(String id)
        {
            this.id = id;
        }

        public void setTitle(String title)
        {
            this.Title = title;
        }

        public List<Student> getStudents()
        {
            return Students;
        }

        public void setStudents(List<Student> Students)
        {
            this.Students = Students;
        }

 }
</code>```

```<code>        package test;

    import java.util.List;
    import javax.xml.bind.annotation.XmlElement;
    import javax.xml.bind.annotation.XmlRootElement;

    @XmlRootElement(name = "StudentList")
    public class StudentList
    {

        private List<Student> Student_info;
        private List<Course> Course_info;

        @XmlElement(name = "Student")
        public List<Student> getStudent_info()
        {
            return Student_info;
        }

        public void setStudent_info(List<Student> Student_info)
        {
            this.Student_info = Student_info;
        }

        @XmlElement(name = "Course")
        public List<Course> getCourse_Info()
        {
            return Course_info;
        }

        public void setCourse_Info(List<Course> Course_info)
        {
            this.Course_info = Course_info;
        }
    }
</code>```

```<code>  package test;

import java.io.File;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;

public class Demo
{
    public static void main(String[] args)
    {

        try
        {

            File file = new File("D:\\xmlfile.xml");
            JAXBContext jaxbContext = JAXBContext.newInstance(StudentList.class);

            Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
            StudentList studentlist = (StudentList) jaxbUnmarshaller.unmarshal(file);
            for (Student emp : studentlist.getStudent_info())
            {
                System.out.println(emp.getAge());
                System.out.println(emp.getName());
                System.out.println(emp.getId());
                System.out.println(emp.getRefid());
            }

        }
        catch (JAXBException e)
        {
            e.printStackTrace();
        }

    }
}
</code>```

Body:
First of all, I am very new to xml world. I am facing problem to extract data from a cross-referenced xml file. Following is an example (modified):

<?xml version="1.0" encoding="UTF-8"?>

<StudentList>
    <Student_info>
    <Student id = "1">
        <Name>Mike</Name>
        <Age>16</Age>
    </Student>
    <Student id="2">
        <Name>Matteo</Name>
        <Age>15</Age>
    </Student>
    <Student id="3">
        <Name>Matt</Name>
        <Age>17</Age>
    </Student>
    <Student id="4">
        <Name>Siri</Name>
        <Age>16</Age>
    </Student>
    <Student id="5">
       <Name>Sara</Name>
       <Age>15</Age>
       </Student>
    </Student_info>

    <Course_info>
       <Course id="PHY101">
            <Title>Physics Fundamentals></Title>

            <Student refid ="1"/>
            <Student refid = "2"/>
            <Student refid = "5"/>
        </Course>

    <Course id = "MATH101">
        <Title>Mathematics Basics</Title>

        <Student refid = "2"/>
        <Student refid = "3"/>
        <Student refid = "4"/>
    </Course>
    </Course_info>
</StudentList>

Now, I would like to get the following output using java:

Course Title: Physics Fundamentals
Name of the enrolled students = Mike, Matteo and Sara

And the same for the other course. How can I do that efficiently using java? My main question is to how to extract information from a cross-referenced element (such as Student refid ="1" in the example)?

An solution that I have found:

Firstly the xml file should be modified as follows:

<?xml version="1.0" encoding="UTF-8"?>

<StudentList>
    <Student_info>
    <Student id = "1">
        <Name>Mike</Name>
        <Age>16</Age>
    </Student>
    <Student id="2">
        <Name>Matteo</Name>
        <Age>15</Age>
    </Student>
    <Student id="3">
        <Name>Matt</Name>
        <Age>17</Age>
    </Student>
    <Student id="4">
        <Name>Siri</Name>
        <Age>16</Age>
    </Student>
    <Student id="5">
       <Name>Sara</Name>
       <Age>15</Age>
       </Student>
    </Student_info>

    <Course_info>
       <Course id="PHY101">
            <Title>Physics Fundamentals></Title>

            <Student>1</Student>
            <Student>2</Student>
            <Student>5</Student>
        </Course>

    <Course id = "MATH101">
        <Title>Mathematics Basics</Title>

        ****
        <Student>3</Student>
        <Student>4</Student>
    </Course>
    </Course_info>
</StudentList>

Now, Student class:

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlID;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;

@XmlRootElement(name = "Student")
@XmlAccessorType(XmlAccessType.FIELD)
public class Student
{

    private String Name;
    private int Age;
    @XmlAttribute(name = "id")
    @XmlID
    private String id;

    public String getName()
    {
        return Name;
    }

    public void setName(String name)
    {
        Name = name;
    }

    public int getAge()
    {
        return Age;
    }

    public void setAge(int age)
    {
        Age = age;
    }

    public String getId()
    {
        return id;
    }

    public void setId(String id)
    {
        this.id = id;
    }
}

Course class:

import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlIDREF;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;

    @XmlRootElement(name = "Course")
    class Course
    {
        @XmlAttribute(name = "cid")
        String id;
        @XmlElement(name = "Title")
        String Title;

        @XmlElement(name="Student")
        @XmlIDREF
        List<Student> student;

        Course(){
            student = new ArrayList<Student>();
        }

        String getID()
        {
            return id;
        }

        String getTitle()
        {
            return Title;
        }

        void setID(String id)
        {
            this.id = id;
        }

        void setTitle(String title)
        {
            this.Title = title;
        }

        List<Student> getStudent()
        {
            return student;
        }

        void setStudents(List<Student> student)
        {
            this.student = student;
        }

 }

StudentList class:

import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name = "StudentList")
public class StudentList
{

    private List<Student> Student_info;
    private List<Course> Course_info;

    @XmlElement(name = "Student")
    public List<Student> getStudent_info()
    {
        return Student_info;
    }

    public void setStudent_info(List<Student> Student_info)
    {
        this.Student_info = Student_info;
    }

    @XmlElement(name = "Course")
    public List<Course> getCourse_Info()
    {
        return Course_info;
    }

    public void setCourse_Info(List<Course> Course_info)
    {
        this.Course_info = Course_info;
    }
}

TextXml class:

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;

    public class TextXml {
          public static void main(String[] args)
            {

                try
                {

                    JAXBContext jc = JAXBContext.newInstance(StudentList.class);
                    Unmarshaller unmarshaller = jc.createUnmarshaller();

                    File xml = new File("NewFile.xml");
                    StudentList studentlist = (StudentList) unmarshaller.unmarshal(xml);

                    for (Course course: studentlist.getCourse_Info()){
                        System.out.println("Course Title: "+course.getTitle());
                        for(Student std: course.getStudent()){
                            System.out.print(std.getName()+" ");
                        }
                        System.out.println();
                    }

                }
                catch (JAXBException e)
                {
                    e.printStackTrace();
                }

            }
        }

Thanks.

Body:
    <?xml version="1.0" encoding="UTF-8"?>
<!-- Student info and students enrollment -->
<StudentList>
    <Student id = "1">
        <Name>Mike</Name>
        <Age>16</Age>
    </Student>
    <Student id="2">
        <Name>Matteo</Name>
        <Age>15</Age>
    </Student>
    <Student id="3">
        <Name>Matt</Name>
        <Age>17</Age>
    </Student>
    <Student id="4">
        <Name>Siri</Name>
        <Age>16</Age>
    </Student>
    <Student id="5">
       <Name>Sara</Name>
       <Age>15</Age>
     </Student>
     <Course id="PHY101">
        <Title>Physics Fundamentals</Title>
        <!-- Reference of the students enrolled in physics course -->
            <Student refid ="1"/>
            <Student refid = "2"/>
     </Course>
     <Course id = "MATH101">
        <Title>Mathematics Basics</Title>
        <!-- Reference of the students enrolled in mathematics course -->
            <Student refid = "2"/>
            <Student refid = "3"/>
            <Student refid = "4"/>
      </Course>
  </StudentList>

 package test;

    import javax.xml.bind.annotation.XmlAccessType;
    import javax.xml.bind.annotation.XmlAccessorType;
    import javax.xml.bind.annotation.XmlAttribute;
    import javax.xml.bind.annotation.XmlRootElement;

    @XmlRootElement(name = "Student")
    @XmlAccessorType(XmlAccessType.FIELD)
    public class Student
    {

        private String Name;
        private int Age;
        @XmlAttribute(name = "id")
        private int id;
        @XmlAttribute(name = "refid")
        private int refid;

        public String getName()
        {
            return Name;
        }

        public void setName(String name)
        {
            Name = name;
        }

        public int getAge()
        {
            return Age;
        }

        public void setAge(int age)
        {
            Age = age;
        }

        public int getId()
        {
            return id;
        }

        public void setId(int id)
        {
            this.id = id;
        }

        public int getRefid()
        {
            return refid;
        }

        public void setRefid(int refid)
        {
            this.refid = refid;
        }

    }

     package test;

    import java.util.List;
    import javax.xml.bind.annotation.XmlAccessType;
    import javax.xml.bind.annotation.XmlAccessorType;
    import javax.xml.bind.annotation.XmlAttribute;
    import javax.xml.bind.annotation.XmlElement;
    import javax.xml.bind.annotation.XmlRootElement;

    @XmlRootElement(name = "Course")
    @XmlAccessorType(XmlAccessType.FIELD)
    public class Course
    {
        @XmlAttribute(name = "id")
        private String id;
        private String Title;
        @XmlElement(name = "Student")
        private List<Student> Students = null;

        public String getID()
        {
            return id;
        }

        public String getTitle()
        {
            return Title;
        }

        public void setID(String id)
        {
            this.id = id;
        }

        public void setTitle(String title)
        {
            this.Title = title;
        }

        public List<Student> getStudents()
        {
            return Students;
        }

        public void setStudents(List<Student> Students)
        {
            this.Students = Students;
        }

 }

        package test;

    import java.util.List;
    import javax.xml.bind.annotation.XmlElement;
    import javax.xml.bind.annotation.XmlRootElement;

    @XmlRootElement(name = "StudentList")
    public class StudentList
    {

        private List<Student> Student_info;
        private List<Course> Course_info;

        @XmlElement(name = "Student")
        public List<Student> getStudent_info()
        {
            return Student_info;
        }

        public void setStudent_info(List<Student> Student_info)
        {
            this.Student_info = Student_info;
        }

        @XmlElement(name = "Course")
        public List<Course> getCourse_Info()
        {
            return Course_info;
        }

        public void setCourse_Info(List<Course> Course_info)
        {
            this.Course_info = Course_info;
        }
    }

  package test;

import java.io.File;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;

public class Demo
{
    public static void main(String[] args)
    {

        try
        {

            File file = new File("D:\\xmlfile.xml");
            JAXBContext jaxbContext = JAXBContext.newInstance(StudentList.class);

            Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
            StudentList studentlist = (StudentList) jaxbUnmarshaller.unmarshal(file);
            for (Student emp : studentlist.getStudent_info())
            {
                System.out.println(emp.getAge());
                System.out.println(emp.getName());
                System.out.println(emp.getId());
                System.out.println(emp.getRefid());
            }

        }
        catch (JAXBException e)
        {
            e.printStackTrace();
        }

    }
}


问:
CSS element not showing over image
I bet this is probably something stupid, I am trying put an absolute element over an image, but its not appearing.

```<code><div class="circle" style="position: absolute; top: 200px; left: 100px;"></div>

                    <img src="images/madison-siteplan.png" class="siteplan" />
</code>```

here is the attentional css for the circle:

```<code>.circle {
            border-radius: 50%;
            width: 100px;
            height: 100px;
            color: red;
            }
</code>```

答:
Move the absolutely positioned element to be after the image. Give that element some visual properties so you can see it... (border, background-color, text...)

#bla {
  width:350px;
  height:350px;
  border-radius: 50%;
  background-color: rgba(255,0,0,0.5);
  position:absolute;
  top: 0;

}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><img src="http://placehold.it/500">
<div id="bla"></div></code>```

Title: CSS element not showing over image

Body:
I bet this is probably something stupid, I am trying put an absolute element over an image, but its not appearing.

here is the attentional css for the circle:

.circle {
            border-radius: 50%;
            width: 100px;
            height: 100px;
            color: red;
            }

Body:
Move the absolutely positioned element to be after the image. Give that element some visual properties so you can see it... (border, background-color, text...)

#bla {
  width:350px;
  height:350px;
  border-radius: 50%;
  background-color: rgba(255,0,0,0.5);
  position:absolute;
  top: 0;

}

<img src="http://placehold.it/500">
<div id="bla"></div>


问:
Populating Elasticsearch Dates From Apache Spark
I have a DataFrame in Spark with a scheme like:

```<code>id: string
style: string
creationdate: string
</code>```

My dates are datetime strings like "yyyy-MM-dd HH:mm:ss.SSS". I am converting "creationdate" from string to date using:

```<code>val df2 = df.withColumn("creationdate2", $"creationdate".cast(DateType))
             .drop($"creationdate")
             .withColumnRenamed("creationdate2", "creationdate")
</code>```

This results in:

```<code>id: string
style: string
creationdate: date
</code>```

I am attempting to populate an Elasticsearch index with the date mapping defined as:

```<code>     "creationdate": {
        "type": "date",
        "format": "yyyy-MM-dd"
      }
</code>```

The String to DateTime conversions appears to match this format upon printing.  However, when I go to populate the index with:

```<code>df2.saveToEs("myindex")
</code>```

I get an error:

```<code> org.apache.spark.util.TaskCompletionListenerException: Found unrecoverable error [169.10.29.240:9200] returned Bad Request(400) - failed to parse [creationdate]; Bailing out..
        at org.apache.spark.TaskContextImpl.markTaskCompleted(TaskContextImpl.scala:105)
        at org.apache.spark.scheduler.Task.run(Task.scala:112)
        at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:282)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
</code>```

According to the guide the date should be able to be parsed since it has been converted to DateType.  Any ideas?  Should the schema be showing DateType instead of date?  Am I doing the conversion wrong?

答:
Solved by taking one more step and converting java.sql.Date back to a string.  Using a UDF:</p>

```<code>val dateToString = udf((date: java.sql.Date) => date.toString)
</code>```

Body:
I have a DataFrame in Spark with a scheme like:

id: string
style: string
creationdate: string

My dates are datetime strings like "yyyy-MM-dd HH:mm:ss.SSS". I am converting "creationdate" from string to date using:

val df2 = df.withColumn("creationdate2", $"creationdate".cast(DateType))
             .drop($"creationdate")
             .withColumnRenamed("creationdate2", "creationdate")

This results in:

id: string
style: string
creationdate: date

I am attempting to populate an Elasticsearch index with the date mapping defined as:

     "creationdate": {
        "type": "date",
        "format": "yyyy-MM-dd"
      }

The String to DateTime conversions appears to match this format upon printing.  However, when I go to populate the index with:

df2.saveToEs("myindex")

I get an error:

 org.apache.spark.util.TaskCompletionListenerException: Found unrecoverable error [169.10.29.240:9200] returned Bad Request(400) - failed to parse [creationdate]; Bailing out..
        at org.apache.spark.TaskContextImpl.markTaskCompleted(TaskContextImpl.scala:105)
        at org.apache.spark.scheduler.Task.run(Task.scala:112)
        at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:282)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)

According to the guide the date should be able to be parsed since it has been converted to DateType.  Any ideas?  Should the schema be showing DateType instead of date?  Am I doing the conversion wrong?

Body:
Solved by taking one more step and converting java.sql.Date back to a string.  Using a UDF:

val dateToString = udf((date: java.sql.Date) => date.toString)


问:
android google map view problem
i want to display google map in android emulator. i also follow the step described in below link.
http://developer.android.com/guide/tutorials/views/hello-mapview.html

when i run my application it will not display google map. just display grids like below.

Please help me to show google map.

thanks in advance.

答:
run  -->  debug Configurations... -->select ur application --> target tab ---> add below line in Additional Emulator Command Line Options

e.g
             -http-proxy http://myproxy:port/

where myproxy= write ur proxy server name (my proxy server is 192.168.0.1)
      port   = port number (my port number )
it like,
   -http-proxy http://192.168.0.1:8080/

Title: android google map view problem


问:
How to store result of dynamically executed stored procedure into a variable?
I am trying to assign result of a stored procedure executed dynamically into a variable. However when i call them, sql throw me this error:

Could not find the stored procedure 'exec dbo.cont_com 3611,892;'

Below is the code snippet I am using:

```<code>declare @procedure_to_call varchar(max);
declare @procedure_result int;

set @procedure_to_call='exec dbo.cont_com 3611,892;'

exec @procedure_result=@procedure_to_call;
</code>```

When I put parenthesis and execute the stored procedure, it works fine:

```<code>exec (@procedure_to_call);
</code>```

But i need to save the return of the @procedure_to_call inside a variable.

This is the sample code for dbo.cont_com SP:

```<code>CREATE PROCEDURE dbo.cont_com
(
    @id_c int,
    @id_f int)
AS
BEGIN

    declare @porcent int;

    select @porcent=p.porcent
    from porcent_table p
    where p.id_c=@id_c
    and p.id_c=@id_f;

    select porcent=@porcent;
    return @porcent;

END
</code>```

Any help will be greatly appreciated.

答:
```<code>set @procedure_to_call='exec dbo.cont_com 3611,892;'

exec @procedure_result=@procedure_to_call;
</code>```

This becomes

```<code>exec exec dbo.cont_com 3611,892; -- hence the error
</code>```

exec (@procedure_to_call) gets around this by exectuing what's in the parentheses as its own activity

Try:

```<code>set @procedure_to_call='dbo.cont_com 3611,892;'
</code>```

Body:
I am trying to assign result of a stored procedure executed dynamically into a variable. However when i call them, sql throw me this error:

Could not find the stored procedure 'exec dbo.cont_com 3611,892;'

Below is the code snippet I am using:

declare @procedure_to_call varchar(max);
declare @procedure_result int;

set @procedure_to_call='exec dbo.cont_com 3611,892;'

exec @procedure_result=@procedure_to_call;

When I put parenthesis and execute the stored procedure, it works fine:

exec (@procedure_to_call);

But i need to save the return of the @procedure_to_call inside a variable.

This is the sample code for dbo.cont_com SP:

CREATE PROCEDURE dbo.cont_com
(
    @id_c int,
    @id_f int)
AS
BEGIN

    declare @porcent int;

    select @porcent=p.porcent
    from porcent_table p
    where p.id_c=@id_c
    and p.id_c=@id_f;

    select porcent=@porcent;
    return @porcent;

END

Any help will be greatly appreciated.

Body:
set @procedure_to_call='exec dbo.cont_com 3611,892;'

exec @procedure_result=@procedure_to_call;

This becomes

exec exec dbo.cont_com 3611,892; -- hence the error

exec (@procedure_to_call) gets around this by exectuing what's in the parentheses as its own activity

Try:

set @procedure_to_call='dbo.cont_com 3611,892;'


问:
Some wired behavior for display inline block
Update
it's a question of whether inline-block elements contains something or not, You can search for it and find a better solution.

The page contains three div(gray rectangle) and the first div(parent) contains three blue child-div. Parent divs are inline-block, child-divs are also the same. Why the first parent-div is moved downwards? I'm supposed that they should be aligned in a line.

```<code><body>
    <section>
        <div class = "container">
            <div class = "load_1"></div>
            <div class = "load_1"></div>
            <div class = "load_1"></div>
        </div>
        <div class = "container">

        </div>
        <div class = "container">

        </div>
    </section>
</body>
</code>```

css

```<code>           section{
                width:100%;
                height:100vh;
                background-color: rgba(236, 240, 241,1.0);
            }
            div.container{
                display: inline-block;
                width:150px;
                height:150px;
                margin:10px;
                background-color: rgba(189, 195, 199,1.0);
                border-radius: 5px;
            }
            div.container:first-child{
                margin-left: 20px;
            }
            div.container .load_1{
                width:20px;
                height:20px;
                display: inline-block;
                background-color: rgba(52, 152, 219,1.0);
            }
</code>```

Please check here in JSfiddle.

答:
Add a vertical-align rule to your div.container element.

See Snippet Below:

section{
   width:100%;
   height:100vh;
   background-color: rgba(236, 240, 241,1.0);
  }
  div.container{
   display: inline-block;
   width:150px;
   height:150px;
   margin:10px;
   background-color: rgba(189, 195, 199,1.0);
   border-radius: 5px;
      vertical-align: top;
  }
  div.container:first-child{
   margin-left: 20px;
  }
  div.container .load_1{
   width:20px;
   height:20px;
   display: inline-block;
   background-color: rgba(52, 152, 219,1.0);
  }```
<pre class="snippet-code-html lang-html prettyprint-override"><code><body>
 <section>
  <div class = "container">
   <div class = "load_1"></div>
   <div class = "load_1"></div>
   <div class = "load_1"></div>
  </div>
  <div class = "container">

  </div>
  <div class = "container">

  </div>
 </section>
</body></code>```

JSFiddle: https://jsfiddle.net/8bmdpqer/

Body:
Update
it's a question of whether inline-block elements contains something or not, You can search for it and find a better solution.

The page contains three div(gray rectangle) and the first div(parent) contains three blue child-div. Parent divs are inline-block, child-divs are also the same. Why the first parent-div is moved downwards? I'm supposed that they should be aligned in a line.

css

           section{
                width:100%;
                height:100vh;
                background-color: rgba(236, 240, 241,1.0);
            }
            div.container{
                display: inline-block;
                width:150px;
                height:150px;
                margin:10px;
                background-color: rgba(189, 195, 199,1.0);
                border-radius: 5px;
            }
            div.container:first-child{
                margin-left: 20px;
            }
            div.container .load_1{
                width:20px;
                height:20px;
                display: inline-block;
                background-color: rgba(52, 152, 219,1.0);
            }

Please check here in JSfiddle.

Body:
Add a vertical-align rule to your div.container element.

See Snippet Below:

section{
   width:100%;
   height:100vh;
   background-color: rgba(236, 240, 241,1.0);
  }
  div.container{
   display: inline-block;
   width:150px;
   height:150px;
   margin:10px;
   background-color: rgba(189, 195, 199,1.0);
   border-radius: 5px;
      vertical-align: top;
  }
  div.container:first-child{
   margin-left: 20px;
  }
  div.container .load_1{
   width:20px;
   height:20px;
   display: inline-block;
   background-color: rgba(52, 152, 219,1.0);
  }

<body>
 <section>
  <div class = "container">
   <div class = "load_1"></div>
   <div class = "load_1"></div>
   <div class = "load_1"></div>
  </div>
  <div class = "container">

  </div>
  <div class = "container">

  </div>
 </section>
</body>

JSFiddle: https://jsfiddle.net/8bmdpqer/


问:
Tool that lists all deprecated classes/methods that are no longer used anywhere?
I need to cleanup a some legacy code. Removing unused code is an important step.

Is there a tool that finds all deprecated code, removes all items which are still used somewhere and gives me a list of unused deprecated code?

For bonus points: Is there a tool which can find unused code non-deprecated code?

I'm aware that this is never perfect but I know for which cases I need special handling (as in DB drivers or classes that are referenced via DI).

答:
I'm not completely certain that I understand your question. Do you want a tool that un-deprecates code that is still referenced? Any IDE will help you with that. Not automatically but removing an @Deprecated annotation is easily done with a global query-and-replace. After you have removed unused code, of course:

If all you want is to remove unused code, I have used the eclipse plugin ucdetector for this purpose in a previous project. While it does not actually remove the unused code it does give you a list of the methods, classes and constants that have no references so you can remove them yourself. This is a good thing.

As you point out yourself, there are some classes/methods that may seem to be unused using static analysis. In my opinion this makes it impossible to automate this task. You the coder will have to analyze every block of code that is reported to be unused.

If you are lucky enough to have excellent test coverage another option is to use a code coverage analysis tool, like cobertura, clover or emma.