Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

Hibernate/JPA criteria query

import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
import org.hibernate.Session;
import org.hibernate.SessionFactory;

try (Session session = sessionFactory.openSession()) {
      CriteriaBuilder criteriaBuilder = session.getCriteriaBuilder();
      CriteriaQuery<Integer> query = criteriaBuilder.createQuery(Integer.class);
      Root<RevisionInfoData> root = query.from(RevisionInfoData.class);
      query
          .select(root.get("revisionNumber"))
          .orderBy(criteriaBuilder.desc(root.get("revisionNumber")));
      return ImmutableSet.copyOf(session.createQuery(query).getResultList());
}
Comment

PREVIOUS NEXT
Code Example
Java :: Child inside NestedScrollView not cover full height of screen 
Java :: java minimize all windows 
Java :: Share Icon/Button 
Java :: Java program to demonstrate working of HashTable 
Java :: dynamic fib 
Java :: how to save rich text format in database using java 
Java :: convert subarray to list java 
Java :: conky cpu temperature 
Java :: Java 8 merge multiple collections. 
Java :: java program to print hexadecimal to decimal number conversion 
Java :: number output swing java 
Java :: Java Default Access Modifier creates error in package two by importing package one 
Java :: zombie testing java 
Java :: cancel block event spigot 
Java :: how to get index of while loop java 
Java :: java find view by id 
Java :: Quartz spring maven driver 
Java :: fail method java 
Java :: mock a service when the method returning void 
Java :: Write program for problem 1 such that every regex runs as its own thread in java 
Java :: Java Creating strings using the new keyword 
Java :: javafx add vm options 
Java :: focus_button_java_swing 
Java :: how to set slected row color in javafx tableview 
Java :: factorial function in java recursion 
Java :: javax.ws.rs.core.response readentity not found 
Java :: Clicking on Fragment goes through in Activity 
Java :: trivers json node as node type 
Java :: Java Static Top-level Class 
Java :: how to make jframe full screen 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =