@NamedNativeQuery(
name = "PostDTO",
query = """
SELECT
p.id AS id,
p.title AS title
FROM Post p
WHERE p.created_on > :fromTimestamp
""",
resultSetMapping = "PostDTO"
)
@SqlResultSetMapping(
name = "PostDTO",
classes = @ConstructorResult(
targetClass = PostDTO.class,
columns = {
@ColumnResult(name = "id"),
@ColumnResult(name = "title")
}
)
)
public class PostDTO {
private Long id;
private String title;
public Long getId() {
return id;
}
public void setId(Number id) {
this.id = id.longValue();
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
}
|