You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: migration-guide.adoc
+47-1Lines changed: 47 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -115,8 +115,54 @@ String isDefault();
115
115
----
116
116
117
117
118
+
[[create-query]]
119
+
== Queries with implicit `select` list and no explicit result type
120
+
121
+
In previous versions, Hibernate allowed a query with no `select` list to be passed to the overload of `createQuery()` with no explicit result type parameter, for example:
122
+
123
+
[source,java]
124
+
List query =
125
+
session.createQuery("from X, Y")
126
+
.getResultList()
127
+
128
+
or:
129
+
130
+
[source,java]
131
+
List query =
132
+
session.createQuery("from X join y")
133
+
.getResultList()
134
+
135
+
The select list was inferred based on the `from` clause.
136
+
137
+
In Hibernate 6 we decided to deprecate this overload of `createQuery()`, since:
138
+
139
+
- it returns a raw type, resulting in compiler warnings in client code, and
140
+
- the second query is truly ambiguous, with no obviously intuitive interpretation.
141
+
142
+
As of Hibernate 7, the method is remains deprecated, and potentially-ambiguous queries _are no longer accepted_.
143
+
Migration paths include:
144
+
145
+
1. explicitly specify the `select` list,
146
+
2. add `X.class` or `Object[].class` as a second argument, to disambiguate the interpretation of the query, or
147
+
3. in the case where the query should return exactly one entity, explicitly assign the alias `this` to that entity.
148
+
149
+
For example, the queries above may be migrated via:
150
+
151
+
[source,java]
152
+
List<Object[]> result =
153
+
session.createQuery("from X, Y", Object[].class)
154
+
.getResultList()
155
+
156
+
or:
157
+
158
+
[source,java]
159
+
List<X> result =
160
+
session.createQuery("from X join y", X.class)
161
+
.getResultList()
162
+
163
+
118
164
[[proxy-annotation]]
119
-
== Replace @Proxy
165
+
== Replace `@Proxy`
120
166
121
167
Applications will need to replace usages of the removed `@Proxy` annotation.
0 commit comments