I have a util.List with offers. The variables of class offer are:
Integer id, Date startDate, Date endDate, String offerMessage, String creationDate, String updateDate.
I generated JPA entities and Controller with NetBeans from a MySQL database where i had set startDate, endDate as Timestamp in the db.
As you can see the annotations in the entity are:
@Basic(optional = false)
@Column(name = "startDate")
@Temporal(TemporalType.TIMESTAMP)
private Date startDate;
@Basic(optional = false)
@Column(name = "endDate")
@Temporal(TemporalType.TIMESTAMP)
private Date endDate;
When i test my axis webservice where i do something like:
in WebService:
reply = _protocol.reply(request);
and in Protocol:
public String reply(String request) throws Exception {
String reply = "I dont understand you!";
try {
if (request.equals("a")) {
OfferJpaController oferJpaController = new OfferJpaController();
List<Offer> allOffers = oferJpaController.findOfferEntities();
Gson gson = new GsonBuilder().registerTypeAdapter(Date.class, new DateTypeAdapter() ).create();
reply = gson.toJson(allOffers);
}
} catch (Exception ex) {
throw ex;
}
return reply;
}
I get Exception: java.lang.reflect.InvocationTargetException Message: java.lang.reflect.InvocationTargetException
As i can imagine, the problem is the util.Date, i searched in other questions here, but i did not managed to solve this. What should i do? Maybe store the Timestamp field as integer in db and make pre-post actions for database conversions?