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
<project> | |
... | |
<build> | |
<plugins> | |
<plugin> | |
<groupId>org.codehaus.mojo</groupId> | |
<artifactId>build-helper-maven-plugin</artifactId> | |
<version>3.0.0</version> | |
<executions> |
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
// Transaction 1: Check that no tweet matches the search string | |
EntityManager em = emf.createEntityManager(); | |
em.getTransaction().begin(); | |
FullTextEntityManager fullTextEm = Search.getFullTextEntityManager(em); | |
QueryBuilder tweetQb = fullTextEm.getSearchFactory().buildQueryBuilder().forEntity(Tweet.class).get(); | |
Query fullTextQuery = tweetQb.keyword().onField(Tweet_.message.getName()).matching(“Message updated”).createQuery(); | |
List results = fullTextEm.createFullTextQuery(fullTextQuery).getResultList(); | |
Assert.assertEquals(0, results.size()); |
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
<dependency> | |
<groupId>org.hibernate</groupId> | |
<artifactId>hibernate-entitymanager</artifactId> | |
<version>${hibernate.version}</version> | |
</dependency> |
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 implements Serializable { | |
@Column | |
@NotNull | |
@Size(min=5, max=20) | |
private String title; | |
… |
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 q = em.createQuery(“SELECT a FROM Author a WHERE a.id = :id”, Author.class); | |
q.setParameter(“id”, 1L); | |
q.setHint(“org.hibernate.comment”, “This is my comment”); | |
Author a = q.getSingleResult(); |
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 a FROM Author a WHERE a.firstName like ‘%and%’ and a.id >= 20 and size(author.books) >= 5 |
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
AuditQuery q = auditReader.createQuery().forRevisionsOfEntity(Book.class, false, true); | |
q.addProjection(AuditEntity.revisionNumber()); | |
q.add(AuditEntity.revisionProperty(“userName”).eq(“User 1”)); | |
List<Number> revisionNumbers = q.getResultList(); |