Util Test Case:
@Test
public void validate() {
Map<String,Object> params = new HashMap<String,Object>();
params.put("code", "23102");
List<ZipCodes> list = (List<ZipCodes>)this.genericDAO.findByNamedQuery("zipCodesList.findByCode",params);
if(list!=null){
for(ZipCodes zipCodes: list)
{
System.out.println(zipCodes.getCounty());
System.out.println(zipCodes.getStateCode());
}
}
}
запрос выбора базы данных и его данных:
выберите * из zip_codes, где код = '23102'
CODE STATE_CODE COUNTY
23102 VA GOOCHLAND
23102 VA HANOVER
23102 VA LOUISA
hql ОБЪЕДИНЕНО:
select zipcodes0_.code as code11_, zipcodes0_.city as city11_, zipcodes0_.county as county11_, zipcodes0_.state_code as state4_11_ from zip_codes zipcodes0_ where zipcodes0_.code='23102'
Генерированные данные имеют все округа с одинаковыми именами.
Не знаете, что происходит не так?
Кто-нибудь может мне помочь?
ZipCodes class
@Entity
@Table(name = "zip_codes")
@NamedQueries(value = {
@NamedQuery(name = "zipCodesList.findByCode", query = "select a from ZipCodes a where a.code=:code")
})
public class ZipCodes implements Serializable{
private static final long serialVersionUID = 1L;
@Id
@Column(name = "code")
private String code;
@Column(name = "state_code")
private String stateCode;
@Column(name = "county")
private String county;
@Column(name = "city")
private String city;
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getStateCode() {
return stateCode;
}
public void setStateCode(String stateCode) {
this.stateCode = stateCode;
}
public String getCounty() {
return county;
}
public void setCounty(String county) {
this.county = county;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
}
где мне не хватает поймать?