|
5 | 5 | package org.hibernate.query.sql.internal; |
6 | 6 |
|
7 | 7 | import java.util.ArrayList; |
8 | | -import java.util.Collections; |
9 | 8 | import java.util.HashSet; |
10 | 9 | import java.util.List; |
11 | 10 | import java.util.Set; |
|
29 | 28 | import org.hibernate.sql.results.spi.ListResultsConsumer; |
30 | 29 | import org.hibernate.sql.results.spi.ResultsConsumer; |
31 | 30 |
|
| 31 | +import static java.util.Collections.emptyList; |
| 32 | + |
32 | 33 | /** |
33 | 34 | * @author Steve Ebersole |
34 | 35 | */ |
@@ -67,7 +68,7 @@ public <T> T executeQuery(DomainQueryExecutionContext executionContext, ResultsC |
67 | 68 |
|
68 | 69 | final QueryParameterBindings queryParameterBindings = executionContext.getQueryParameterBindings(); |
69 | 70 | if ( parameterList == null || parameterList.isEmpty() ) { |
70 | | - jdbcParameterBinders = Collections.emptyList(); |
| 71 | + jdbcParameterBinders = emptyList(); |
71 | 72 | jdbcParameterBindings = JdbcParameterBindings.NO_BINDINGS; |
72 | 73 | } |
73 | 74 | else { |
@@ -102,83 +103,83 @@ public <T> T executeQuery(DomainQueryExecutionContext executionContext, ResultsC |
102 | 103 | public List<R> performList(DomainQueryExecutionContext executionContext) { |
103 | 104 | final QueryOptions queryOptions = executionContext.getQueryOptions(); |
104 | 105 | if ( queryOptions.getEffectiveLimit().getMaxRowsJpa() == 0 ) { |
105 | | - return Collections.emptyList(); |
106 | | - } |
107 | | - final List<JdbcParameterBinder> jdbcParameterBinders; |
108 | | - final JdbcParameterBindings jdbcParameterBindings; |
109 | | - |
110 | | - final QueryParameterBindings queryParameterBindings = executionContext.getQueryParameterBindings(); |
111 | | - if ( parameterList == null || parameterList.isEmpty() ) { |
112 | | - jdbcParameterBinders = Collections.emptyList(); |
113 | | - jdbcParameterBindings = JdbcParameterBindings.NO_BINDINGS; |
| 106 | + return emptyList(); |
114 | 107 | } |
115 | 108 | else { |
116 | | - jdbcParameterBinders = new ArrayList<>( parameterList.size() ); |
117 | | - jdbcParameterBindings = new JdbcParameterBindingsImpl( |
118 | | - queryParameterBindings, |
119 | | - parameterList, |
| 109 | + final List<JdbcParameterBinder> jdbcParameterBinders; |
| 110 | + final JdbcParameterBindings jdbcParameterBindings; |
| 111 | + if ( parameterList == null || parameterList.isEmpty() ) { |
| 112 | + jdbcParameterBinders = emptyList(); |
| 113 | + jdbcParameterBindings = JdbcParameterBindings.NO_BINDINGS; |
| 114 | + } |
| 115 | + else { |
| 116 | + jdbcParameterBinders = new ArrayList<>( parameterList.size() ); |
| 117 | + jdbcParameterBindings = new JdbcParameterBindingsImpl( |
| 118 | + executionContext.getQueryParameterBindings(), |
| 119 | + parameterList, |
| 120 | + jdbcParameterBinders, |
| 121 | + executionContext.getSession().getFactory() |
| 122 | + ); |
| 123 | + } |
| 124 | + |
| 125 | + final JdbcOperationQuerySelect jdbcSelect = new JdbcOperationQuerySelect( |
| 126 | + sql, |
120 | 127 | jdbcParameterBinders, |
121 | | - executionContext.getSession().getFactory() |
| 128 | + resultSetMapping, |
| 129 | + affectedTableNames |
122 | 130 | ); |
123 | | - } |
124 | 131 |
|
125 | | - final JdbcOperationQuerySelect jdbcSelect = new JdbcOperationQuerySelect( |
126 | | - sql, |
127 | | - jdbcParameterBinders, |
128 | | - resultSetMapping, |
129 | | - affectedTableNames |
130 | | - ); |
131 | | - |
132 | | - executionContext.getSession().autoFlushIfRequired( jdbcSelect.getAffectedTableNames() ); |
133 | | - return executionContext.getSession().getJdbcServices().getJdbcSelectExecutor().list( |
134 | | - jdbcSelect, |
135 | | - jdbcParameterBindings, |
136 | | - SqmJdbcExecutionContextAdapter.usingLockingAndPaging( executionContext ), |
137 | | - null, |
138 | | - queryOptions.getUniqueSemantic() == null ? |
139 | | - ListResultsConsumer.UniqueSemantic.NEVER : |
140 | | - queryOptions.getUniqueSemantic() |
141 | | - ); |
| 132 | + executionContext.getSession().autoFlushIfRequired( jdbcSelect.getAffectedTableNames() ); |
| 133 | + return executionContext.getSession().getJdbcServices().getJdbcSelectExecutor().list( |
| 134 | + jdbcSelect, |
| 135 | + jdbcParameterBindings, |
| 136 | + SqmJdbcExecutionContextAdapter.usingLockingAndPaging( executionContext ), |
| 137 | + null, |
| 138 | + queryOptions.getUniqueSemantic() == null |
| 139 | + ? ListResultsConsumer.UniqueSemantic.NEVER |
| 140 | + : queryOptions.getUniqueSemantic() |
| 141 | + ); |
| 142 | + } |
142 | 143 | } |
143 | 144 |
|
144 | 145 | @Override |
145 | 146 | public ScrollableResultsImplementor<R> performScroll(ScrollMode scrollMode, DomainQueryExecutionContext executionContext) { |
146 | 147 | if ( executionContext.getQueryOptions().getEffectiveLimit().getMaxRowsJpa() == 0 ) { |
147 | 148 | return EmptyScrollableResults.instance(); |
148 | 149 | } |
149 | | - final List<JdbcParameterBinder> jdbcParameterBinders; |
150 | | - final JdbcParameterBindings jdbcParameterBindings; |
151 | | - |
152 | | - final QueryParameterBindings queryParameterBindings = executionContext.getQueryParameterBindings(); |
153 | | - if ( parameterList == null || parameterList.isEmpty() ) { |
154 | | - jdbcParameterBinders = Collections.emptyList(); |
155 | | - jdbcParameterBindings = JdbcParameterBindings.NO_BINDINGS; |
156 | | - } |
157 | 150 | else { |
158 | | - jdbcParameterBinders = new ArrayList<>( parameterList.size() ); |
159 | | - jdbcParameterBindings = new JdbcParameterBindingsImpl( |
160 | | - queryParameterBindings, |
161 | | - parameterList, |
| 151 | + final List<JdbcParameterBinder> jdbcParameterBinders; |
| 152 | + final JdbcParameterBindings jdbcParameterBindings; |
| 153 | + if ( parameterList == null || parameterList.isEmpty() ) { |
| 154 | + jdbcParameterBinders = emptyList(); |
| 155 | + jdbcParameterBindings = JdbcParameterBindings.NO_BINDINGS; |
| 156 | + } |
| 157 | + else { |
| 158 | + jdbcParameterBinders = new ArrayList<>( parameterList.size() ); |
| 159 | + jdbcParameterBindings = new JdbcParameterBindingsImpl( |
| 160 | + executionContext.getQueryParameterBindings(), |
| 161 | + parameterList, |
| 162 | + jdbcParameterBinders, |
| 163 | + executionContext.getSession().getFactory() |
| 164 | + ); |
| 165 | + } |
| 166 | + |
| 167 | + final JdbcOperationQuerySelect jdbcSelect = new JdbcOperationQuerySelect( |
| 168 | + sql, |
162 | 169 | jdbcParameterBinders, |
163 | | - executionContext.getSession().getFactory() |
| 170 | + resultSetMapping, |
| 171 | + affectedTableNames |
164 | 172 | ); |
165 | | - } |
166 | 173 |
|
167 | | - final JdbcOperationQuerySelect jdbcSelect = new JdbcOperationQuerySelect( |
168 | | - sql, |
169 | | - jdbcParameterBinders, |
170 | | - resultSetMapping, |
171 | | - affectedTableNames |
172 | | - ); |
173 | | - |
174 | | - executionContext.getSession().autoFlushIfRequired( jdbcSelect.getAffectedTableNames() ); |
175 | | - return executionContext.getSession().getJdbcServices().getJdbcSelectExecutor().scroll( |
176 | | - jdbcSelect, |
177 | | - scrollMode, |
178 | | - jdbcParameterBindings, |
179 | | - SqmJdbcExecutionContextAdapter.usingLockingAndPaging( executionContext ), |
180 | | - null, |
181 | | - -1 |
182 | | - ); |
| 174 | + executionContext.getSession().autoFlushIfRequired( jdbcSelect.getAffectedTableNames() ); |
| 175 | + return executionContext.getSession().getJdbcServices().getJdbcSelectExecutor().scroll( |
| 176 | + jdbcSelect, |
| 177 | + scrollMode, |
| 178 | + jdbcParameterBindings, |
| 179 | + SqmJdbcExecutionContextAdapter.usingLockingAndPaging( executionContext ), |
| 180 | + null, |
| 181 | + -1 |
| 182 | + ); |
| 183 | + } |
183 | 184 | } |
184 | 185 | } |
0 commit comments