@@ -0,0 +1,2591 @@
+package com.vladmihalcea.book.hpjp.jdbc.caching;%0A%0Aimport com.vladmihalcea.book.hpjp.util.AbstractOracleIntegrationTest;%0Aimport com.vladmihalcea.book.hpjp.util.AbstractSQLServerIntegrationTest;%0Aimport org.junit.Test;%0A%0Aimport javax.persistence.Entity;%0Aimport javax.persistence.Id;%0Aimport javax.persistence.Table;%0Aimport javax.persistence.Tuple;%0Aimport java.sql.PreparedStatement;%0Aimport java.sql.ResultSet;%0Aimport java.sql.SQLException;%0Aimport java.util.List;%0A%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.fail;%0A%0A/**%0A * @author Vlad Mihalcea%0A */%0Apublic class SQLServerPreparedStatementLifecycleTest extends AbstractSQLServerIntegrationTest %7B%0A%0A    public static final String SELECT_POST = %22SELECT id, title FROM post%22;%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    @Test%0A    public void testPreparedStatement() %7B%0A        doInJPA(entityManager -%3E %7B%0A            for (long i = 1; i %3C= 3; i++) %7B%0A                entityManager.persist(%0A                    new Post()%0A                        .setId(i)%0A                        .setTitle(String.format(%22High-Performance Java Persistence, part %25d%22, i))%0A                );%0A            %7D%0A        %7D);%0A        doInJDBC(connection -%3E %7B%0A            PreparedStatement preparedStatement = null;%0A            ResultSet resultSet = null;%0A            try %7B%0A                preparedStatement = connection.prepareStatement(SELECT_POST);%0A%0A                resultSet = preparedStatement.executeQuery();%0A%0A                resultSet.close();%0A%0A                resultSet = preparedStatement.executeQuery();%0A%0A                resultSet.close();%0A%0A                resultSet = preparedStatement.executeQuery();%0A            %7D catch (SQLException e) %7B%0A                fail(e.getMessage());%0A            %7D finally %7B%0A                if(resultSet != null) %7B%0A                    resultSet.close();%0A                %7D%0A                if (preparedStatement != null) %7B%0A                    preparedStatement.close();%0A                %7D%0A            %7D%0A        %7D);%0A    %7D%0A%0A    @Entity(name = %22Post%22)%0A    @Table(name = %22post%22)%0A    public static class Post %7B%0A%0A        @Id%0A        private Long id;%0A%0A        private String title;%0A%0A        public Long getId() %7B%0A            return id;%0A        %7D%0A%0A        public Post setId(Long id) %7B%0A            this.id = id;%0A            return this;%0A        %7D%0A%0A        public String getTitle() %7B%0A            return title;%0A        %7D%0A%0A        public Post setTitle(String title) %7B%0A            this.title = title;%0A            return this;%0A        %7D%0A    %7D%0A%7D%0A

Add SQL Server PreparedStatement lifecycle test