8
8
9
9
import java .util .List ;
10
10
11
+ import org .hibernate .testing .TestForIssue ;
11
12
import org .hibernate .testing .orm .junit .DomainModel ;
12
13
import org .hibernate .testing .orm .junit .SessionFactory ;
13
14
import org .hibernate .testing .orm .junit .SessionFactoryScope ;
24
25
import jakarta .persistence .NamedQuery ;
25
26
import jakarta .persistence .Query ;
26
27
28
+ import static org .junit .jupiter .api .Assertions .assertDoesNotThrow ;
27
29
import static org .junit .jupiter .api .Assertions .assertEquals ;
28
30
29
31
@@ -71,6 +73,19 @@ public void testNamedQueriesOrdinalParametersAreOneBased(SessionFactoryScope sco
71
73
);
72
74
}
73
75
76
+ @ Test
77
+ @ TestForIssue ( jiraKey = "HHH-15263" )
78
+ public void testNoExceptionThrownForNamedUpdate (SessionFactoryScope scope ) {
79
+ scope .inTransaction (
80
+ session -> {
81
+ Query query = session .getNamedQuery ( "NamedUpdate" );
82
+ query .setParameter ( 1 , GAME_TITLES [0 ] + " 2" );
83
+ query .setParameter ( 2 , GAME_TITLES [0 ] );
84
+ assertDoesNotThrow ( () -> query .executeUpdate (), "without fixing, 'java.lang.IllegalStateException: Expecting a SELECT query' exception would be thrown" );
85
+ }
86
+ );
87
+ }
88
+
74
89
@ Test
75
90
public void testNativeNamedQueriesOrdinalParametersAreOneBased (SessionFactoryScope scope ) {
76
91
scope .inTransaction (
@@ -84,7 +99,10 @@ public void testNativeNamedQueriesOrdinalParametersAreOneBased(SessionFactorySco
84
99
}
85
100
86
101
@ Entity (name = "Game" )
87
- @ NamedQueries (@ NamedQuery (name = "NamedQuery" , query = "select g from Game g where title = ?1" ))
102
+ @ NamedQueries ({
103
+ @ NamedQuery (name = "NamedQuery" , query = "select g from Game g where title = ?1" ),
104
+ @ NamedQuery (name = "NamedUpdate" , query = "update Game set title = ?1 where title = ?2" )
105
+ })
88
106
@ NamedNativeQueries (@ NamedNativeQuery (name = "NamedNativeQuery" , query = "select * from Game g where title = ?" ))
89
107
public static class Game {
90
108
private Long id ;
0 commit comments