|
| 1 | +/* |
| 2 | + * Hibernate, Relational Persistence for Idiomatic Java |
| 3 | + * |
| 4 | + * License: GNU Lesser General Public License (LGPL), version 2.1 or later |
| 5 | + * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html |
| 6 | + */ |
| 7 | +package org.hibernate.orm.test.query.hql; |
| 8 | + |
| 9 | +import org.hibernate.testing.TestForIssue; |
| 10 | +import org.hibernate.testing.jdbc.SQLStatementInspector; |
| 11 | +import org.hibernate.testing.orm.junit.DomainModel; |
| 12 | +import org.hibernate.testing.orm.junit.ServiceRegistry; |
| 13 | +import org.hibernate.testing.orm.junit.SessionFactory; |
| 14 | +import org.hibernate.testing.orm.junit.SessionFactoryScope; |
| 15 | +import org.junit.jupiter.api.Test; |
| 16 | + |
| 17 | +import jakarta.persistence.Entity; |
| 18 | +import jakarta.persistence.GeneratedValue; |
| 19 | +import jakarta.persistence.Id; |
| 20 | + |
| 21 | +@ServiceRegistry |
| 22 | +@DomainModel( annotatedClasses = { |
| 23 | + InsertSelectTests.EntityEntry.class |
| 24 | +}) |
| 25 | +@SessionFactory(statementInspectorClass = SQLStatementInspector.class) |
| 26 | +public class InsertSelectTests { |
| 27 | + |
| 28 | + @Test |
| 29 | + @TestForIssue( jiraKey = "HHH-15527") |
| 30 | + public void testInsertSelectGeneratedAssigned(SessionFactoryScope scope) { |
| 31 | + final SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); |
| 32 | + scope.inTransaction( |
| 33 | + session -> { |
| 34 | + statementInspector.clear(); |
| 35 | + session.createMutationQuery("insert into EntityEntry (id, name) select 1, 'abc' from EntityEntry e").executeUpdate(); |
| 36 | + statementInspector.assertExecutedCount( 1 ); |
| 37 | + } |
| 38 | + ); |
| 39 | + } |
| 40 | + |
| 41 | + @Entity(name = "EntityEntry") |
| 42 | + public static class EntityEntry { |
| 43 | + @Id |
| 44 | + @GeneratedValue |
| 45 | + Integer id; |
| 46 | + String name; |
| 47 | + } |
| 48 | +} |
0 commit comments