Executing sql statements as a batch through hibernate

They are two ways to execute sql statements as batch in hibernate, which are 1) Work 2) ReturningWork This approach is useful when we want to perform batch operations directly on the database instead of indirectly through hibernate. First we will implement the Work interface as shown below JdbcWork class JdbcWork implements Work { private… Continue reading Executing sql statements as a batch through hibernate

Loading multiple instances by list of entity ids

From hibernate 5.1 we can load multiple instances of same class type in one shot by using the list of ids. The below code gives an example of this import java.util.List; import org.hibernate.MultiIdentifierLoadAccess; import org.hibernate.Session; import org.hibernate.SessionFactory; import model.Series; public class HibernateDemo { public static void main(String[] args) { SessionFactory sessionFactory = HibernateUtil.createSessionFactory(); Session session… Continue reading Loading multiple instances by list of entity ids