@Entity
@Table(name = "Person")
@NamedQueries({
@NamedQuery(
name = "com.syan.dto.Person.findPerson",
query = "SELECT pv FROM Person pv WHERE id = :id"
)
@Column(name = "id", nullable = false)
private Long id;
@Column(name = "visitDate", nullable = false)
private Timestamp visitDate;
public Long getId() {
return id;
}
public void setId(Long id) {
}
@JsonProperty
public Timestamp getVisitDate() {
return visitDate;
}
@JsonProperty
public void setVisitDate(Timestamp visitDate) {
this.visitDate = visitDate;
}
}
PersonDAO
========================
public List<Person> findPerson(long id) {
return list(namedQuery("com.truecaller.rest.dto.findPerson")
.setParameter("id", id)
}
PersonResource
==========================
@Path("/person")
@Produces(MediaType.APPLICATION_JSON)
public class PersonResource {
private final PersonDAO personDAO;
@GET
@Path("/{Id}")
@Produces(MediaType.APPLICATION_JSON)
@UnitOfWork
public List<Person> listPerson(
@PathParam("idd") LongParam id) {
Long userId = id.get();
return personDAO.findPerson(userId);
}
}
Thanks
Syan