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
StoredProcedureQuery query = this.em.createStoredProcedureQuery("get_reviews", Review.class); | |
query.registerStoredProcedureParameter(1, void.class, ParameterMode.REF_CURSOR); | |
query.registerStoredProcedureParameter(2, Long.class, ParameterMode.IN); | |
query.setParameter(2, b.getId()); | |
List<Review> reviews = query.getResultList(); |
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
<persistence> | |
<persistence-unit name="my-persistence-unit"> | |
... | |
<properties> | |
<property name="hibernate.generate_statistics" value="true" /> | |
... | |
</properties> | |
</persistence-unit> |
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
@Entity | |
@DynamicUpdate | |
public class Book { | |
@Id | |
@GeneratedValue(strategy = GenerationType.AUTO) | |
@Column(name = "id", updatable = false, nullable = false) | |
private Long id; | |
@Version |
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
Order o = em.find(Order.class, 1L); | |
OrderItem i = new OrderItem(); | |
i.setOrder(o); | |
o.getItems().add(i); | |
em.persist(i); |
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
@Entity | |
public class Author { | |
@Id | |
private Long id; | |
… | |
} |
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
@Entity | |
public class Book { | |
@Min(100) | |
@Max(1000) | |
private int numPages; | |
… | |
} |
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
TypedQuery<Book> q = em.createQuery("SELECT b FROM Book b " | |
+ "WHERE :double2 > function('calculate', b.price, :double1)" | |
, Book.class); |
NewerOlder