Skip to content

Instantly share code, notes, and snippets.

@thjanssen
Last active July 11, 2016 12:52
Show Gist options
  • Save thjanssen/6b233c442233ef914d51c076e1860b2c to your computer and use it in GitHub Desktop.
Save thjanssen/6b233c442233ef914d51c076e1860b2c to your computer and use it in GitHub Desktop.
Book b = (Book) em.createNativeQuery("SELECT * FROM book b WHERE id = 1", Book.class).getSingleResult();
em.createNativeQuery("SELECT * FROM book b WHERE id = 1", "BookMapping").getSingleResult();
@SqlResultSetMapping(
name = "BookMapping",
entities = @EntityResult(
entityClass = Book.class,
fields = {
@FieldResult(name = "id", column = "id"),
@FieldResult(name = "version", column = "version"),
@FieldResult(name = "title", column = "title"),
@FieldResult(name = "publishingDate", column = "publishingDate"),
@FieldResult(name = "publisher", column = "publisherid")}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment