Skip to content

Commit 2f2fd3d

Browse files
committed
retrospectively mark operations @Incubating
New API operations should generally be marked @Incubating, especially when they occur on prominent interfaces like Session, Query, or SessionFactory. These ones weren't. (Sometimes we forget.) And there was a reason they should have been: their signatures are not type safe, featuring an unbound type parameter in the return type, even though their type argument is reified internally. So a RootGraph<Book> can masquerade as a RootGraph<Author>. This is a big antipattern that I've been trying to systematically root out throughout the whole codebase.
1 parent 092f7d8 commit 2f2fd3d

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

hibernate-core/src/main/java/org/hibernate/SessionFactory.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,7 @@ default <T> RootGraph<T> parseEntityGraph(Class<T> rootEntityClass, CharSequence
543543
*
544544
* @since 7.0
545545
*/
546+
@Incubating
546547
default <T> RootGraph<T> parseEntityGraph(String rootEntityName, CharSequence graphText) {
547548
return GraphParser.parse( rootEntityName, graphText.toString(), unwrap( SessionFactoryImplementor.class ) );
548549
}
@@ -560,6 +561,7 @@ default <T> RootGraph<T> parseEntityGraph(String rootEntityName, CharSequence gr
560561
*
561562
* @since 7.0
562563
*/
564+
@Incubating
563565
default <T> RootGraph<T> parseEntityGraph(CharSequence graphText) {
564566
return GraphParser.parse( graphText.toString(), unwrap( SessionFactoryImplementor.class ) );
565567
}

hibernate-core/src/main/java/org/hibernate/graph/GraphParser.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import jakarta.persistence.EntityManagerFactory;
1010
import jakarta.persistence.Subgraph;
1111

12+
import org.hibernate.Incubating;
1213
import org.hibernate.SessionFactory;
1314
import org.hibernate.engine.spi.SessionFactoryImplementor;
1415
import org.hibernate.engine.spi.SessionImplementor;
@@ -89,6 +90,7 @@ public static <T> RootGraph<T> parse(
8990
*
9091
* @since 7.0
9192
*/
93+
@Incubating
9294
public static <T> RootGraph<T> parse(
9395
final String rootEntityName,
9496
final CharSequence graphText,
@@ -117,7 +119,8 @@ public static <T> RootGraph<T> parse(
117119
*
118120
* @since 7.0
119121
*/
120-
public static <T> RootGraph<T> parse(
122+
@Incubating
123+
public static <T> RootGraph<T> parse(
121124
final CharSequence graphText,
122125
final SessionFactory sessionFactory) {
123126
if ( graphText == null ) {

0 commit comments

Comments
 (0)