Last active
November 3, 2015 19:38
-
-
Save thjanssen/d835a371e938883a56b1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CriteriaBuilder cb = this.em.getCriteriaBuilder(); | |
// create update | |
CriteriaUpdate<Order> update = cb.createCriteriaUpdate(Order.class); | |
// set the root class | |
Root e = update.from(Order.class); | |
// set update and where clause | |
update.set("amount", newAmount); | |
update.where(cb.greaterThanOrEqualTo(e.get("amount"), oldAmount)); | |
// perform update | |
this.em.createQuery(update).executeUpdate(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
EntityGraph graph = this.em.createEntityGraph(Author.class); | |
Subgraph<Book> bookSubGraph = graph.addSubgraph(Author_.books); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT DISTINCT a FROM Author a JOIN FETCH a.books b |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ManyToMany( mappedBy="authors", fetch=FetchType.LAZY) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@NamedEntityGraph(name = "graph.AuthorBooksReviews", | |
attributeNodes = @NamedAttributeNode(value = "books")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@NamedStoredProcedureQuery( | |
name = "getBooks", | |
procedureName = "get_books", | |
resultClasses = Book.class, | |
parameters = { @StoredProcedureParameter(mode = ParameterMode.REF_CURSOR, type = void.class) } | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment