@@ -0,0 +1,2464 @@
+package com.vladmihalcea.book.hpjp.hibernate.query;%0A%0Aimport com.vladmihalcea.book.hpjp.util.AbstractTest;%0Aimport com.vladmihalcea.book.hpjp.util.providers.Database;%0Aimport org.junit.Test;%0A%0Aimport javax.persistence.*;%0Aimport java.util.ArrayList;%0Aimport java.util.Arrays;%0Aimport java.util.List;%0Aimport java.util.Properties;%0Aimport java.util.stream.Collectors;%0A%0Aimport static org.junit.Assert.assertEquals;%0A%0A/**%0A * @author Vlad Mihalcea%0A */%0Apublic class InQueryTest extends AbstractTest %7B%0A%0A    @Override%0A    protected Class%3C?%3E%5B%5D entities() %7B%0A        return new Class%3C?%3E%5B%5D%7B%0A            Post.class%0A        %7D;%0A    %7D%0A%0A    @Override%0A    protected void additionalProperties(Properties properties) %7B%0A        properties.put(%22hibernate.jdbc.batch_size%22, %2250%22);%0A        properties.put(%22hibernate.order_inserts%22, %22true%22);%0A        properties.put(%22hibernate.query.in_clause_parameter_padding%22, %22true%22);%0A    %7D%0A%0A    @Test%0A    public void testPadding() %7B%0A        doInJPA(entityManager -%3E %7B%0A            for (int i = 1; i %3C= 15; i++) %7B%0A                Post post = new Post();%0A                post.setId(i);%0A                post.setTitle(String.format(%22Post no. %25d%22, i));%0A%0A                entityManager.persist(post);%0A            %7D%0A        %7D);%0A%0A        doInJPA(entityManager -%3E %7B%0A            assertEquals(3, getPostByIds(entityManager, 1, 2, 3).size());%0A            assertEquals(4, getPostByIds(entityManager, 1, 2, 3, 4).size());%0A            assertEquals(5, getPostByIds(entityManager, 1, 2, 3, 4, 5).size());%0A            assertEquals(6, getPostByIds(entityManager, 1, 2, 3, 4, 5, 6).size());%0A        %7D);%0A    %7D%0A%0A    List%3CPost%3E getPostByIds(EntityManager entityManager, Integer... ids) %7B%0A        return entityManager.createQuery(%0A            %22select p %22 +%0A            %22from Post p %22 +%0A            %22where p.id in :ids%22, Post.class)%0A        .setParameter(%22ids%22, Arrays.asList(ids))%0A        .getResultList();%0A    %7D%0A%0A    @Entity(name = %22Post%22)%0A    @Table(name = %22post%22)%0A    public static class Post %7B%0A%0A        @Id%0A        private Integer id;%0A%0A        private String title;%0A%0A        public Post() %7B%7D%0A%0A        public Post(String title) %7B%0A            this.title = title;%0A        %7D%0A%0A        public Integer getId() %7B%0A            return id;%0A        %7D%0A%0A        public void setId(Integer id) %7B%0A            this.id = id;%0A        %7D%0A%0A        public String getTitle() %7B%0A            return title;%0A        %7D%0A%0A        public void setTitle(String title) %7B%0A            this.title = title;%0A        %7D%0A    %7D%0A%7D%0A

Add in clause parameter padding