I have issues like if I modify or filter the query in DAO then the JSON result is not coming, otherwise it's working. But I need to filter the query. All details are:
Table details: Address(addressID, road, state, code)
Entity model (Address.java):
@Entity
public class Address(){
@Id
int addressID;
String code;
//getter + setter methods
}
I only need addressID
and code
, only these two fields. So, I mapped only these two and I don't need the other fields.
Action class (JSONData.java):
public class JSONData extends ActionSupport{
private List<Address> address;
//getter, setter
public String jsonFormatDate() {
AddressDAO dao = new AddressDAO();
address = dao.listOfAllAddresses();
return SUCCESS;
}
}
DAO class (AddressDAO.java):
public class AddressDAO{
public List<Address> listOfAllAddresses() {
.....
List list = s.createQuery("from Address").list();
.....
return list;
}
}
If I use the query "from Address"
then the JSON output is successful and I may easily use that result to render the JSP page.
But if I modify the query and filter like "select a.addressID, a.code from Address a"
then there is no JSON output. Moreover, if I also use the where
clause, then no JSON output. If I run this form DAO layer, the query executes the proper output. But not from the JSON.
What things I need to include to get the JSON output by using some filtering rules.