HHH-17492 Add test for issue
This commit is contained in:
parent
7703648f1e
commit
9c18319c1c
|
@ -6,6 +6,7 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.orm.test.query.hql;
|
package org.hibernate.orm.test.query.hql;
|
||||||
|
|
||||||
|
import java.math.BigInteger;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -14,27 +15,30 @@ import java.util.List;
|
||||||
import org.hibernate.boot.MetadataSources;
|
import org.hibernate.boot.MetadataSources;
|
||||||
import org.hibernate.query.Query;
|
import org.hibernate.query.Query;
|
||||||
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
|
||||||
import org.hibernate.testing.orm.domain.contacts.Contact;
|
import org.hibernate.testing.orm.domain.contacts.Contact;
|
||||||
import org.hibernate.testing.orm.domain.contacts.ContactsDomainModel;
|
import org.hibernate.testing.orm.domain.contacts.ContactsDomainModel;
|
||||||
import org.hibernate.testing.orm.junit.BaseSessionFactoryFunctionalTest;
|
import org.hibernate.testing.orm.junit.BaseSessionFactoryFunctionalTest;
|
||||||
|
import org.hibernate.testing.orm.junit.Jira;
|
||||||
import org.junit.jupiter.api.AfterAll;
|
import org.junit.jupiter.api.AfterAll;
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.Id;
|
||||||
|
|
||||||
import static org.hamcrest.CoreMatchers.is;
|
import static org.hamcrest.CoreMatchers.is;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Andrea Boriero
|
* @author Andrea Boriero
|
||||||
*/
|
*/
|
||||||
@TestForIssue(jiraKey = "HHH-10893")
|
|
||||||
public class MultiValuedParameterTest extends BaseSessionFactoryFunctionalTest {
|
public class MultiValuedParameterTest extends BaseSessionFactoryFunctionalTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void applyMetadataSources(MetadataSources metadataSources) {
|
protected void applyMetadataSources(MetadataSources metadataSources) {
|
||||||
super.applyMetadataSources( metadataSources );
|
super.applyMetadataSources( metadataSources );
|
||||||
ContactsDomainModel.applyContactsModel( metadataSources );
|
ContactsDomainModel.applyContactsModel( metadataSources );
|
||||||
|
metadataSources.addAnnotatedClass( EntityWithNumericId.class );
|
||||||
}
|
}
|
||||||
|
|
||||||
@BeforeAll
|
@BeforeAll
|
||||||
|
@ -48,13 +52,17 @@ public class MultiValuedParameterTest extends BaseSessionFactoryFunctionalTest {
|
||||||
Contact.Gender.MALE,
|
Contact.Gender.MALE,
|
||||||
LocalDate.now()
|
LocalDate.now()
|
||||||
);
|
);
|
||||||
session.save( p1 );
|
session.persist( p1 );
|
||||||
|
if ( i < 3 ) {
|
||||||
|
session.persist( new EntityWithNumericId( BigInteger.valueOf( i ) ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@Jira( "https://hibernate.atlassian.net/browse/HHH-10893" )
|
||||||
public void testParameterListIn() {
|
public void testParameterListIn() {
|
||||||
inTransaction(
|
inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
|
@ -80,8 +88,38 @@ public class MultiValuedParameterTest extends BaseSessionFactoryFunctionalTest {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Jira( "https://hibernate.atlassian.net/browse/HHH-17492" )
|
||||||
|
public void test() {
|
||||||
|
inTransaction( session -> {
|
||||||
|
final List<BigInteger> ids = List.of( BigInteger.ZERO, BigInteger.ONE, BigInteger.TWO );
|
||||||
|
final List<EntityWithNumericId> resultList = session.createQuery(
|
||||||
|
"select id from EntityWithNumericId e WHERE e.id in (:ids)",
|
||||||
|
EntityWithNumericId.class
|
||||||
|
).setParameter( "ids", ids ).getResultList();
|
||||||
|
assertThat( resultList.size(), is( 3 ) );
|
||||||
|
assertThat( resultList, is( ids ) );
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
@AfterAll
|
@AfterAll
|
||||||
public void cleanupData() {
|
public void cleanupData() {
|
||||||
inTransaction( session -> session.createQuery( "delete Contact" ).executeUpdate() );
|
inTransaction( session -> {
|
||||||
|
session.createMutationQuery( "delete Contact" ).executeUpdate();
|
||||||
|
session.createMutationQuery( "delete EntityWithNumericId" ).executeUpdate();
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Entity( name = "EntityWithNumericId" )
|
||||||
|
public static class EntityWithNumericId {
|
||||||
|
@Id
|
||||||
|
private BigInteger id;
|
||||||
|
|
||||||
|
public EntityWithNumericId() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntityWithNumericId(BigInteger id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue