HHH-17801 Resolve enum basic types to avoid type validation issues
This commit is contained in:
parent
5d3ad275cd
commit
a5bfed34b4
|
@ -295,7 +295,10 @@ public class InferredBasicValueResolver {
|
|||
final JdbcType jdbcType = explicitJdbcType == null
|
||||
? enumJavaType.getRecommendedJdbcType( stdIndicators )
|
||||
: explicitJdbcType;
|
||||
final BasicTypeImpl<E> basicType = new BasicTypeImpl<>( enumJavaType, jdbcType );
|
||||
final BasicType<E> basicType = bootstrapContext.getTypeConfiguration().getBasicTypeRegistry().resolve(
|
||||
enumJavaType,
|
||||
jdbcType
|
||||
);
|
||||
bootstrapContext.registerAdHocBasicType( basicType );
|
||||
return new InferredBasicValueResolution<>(
|
||||
basicType,
|
||||
|
|
|
@ -8,6 +8,7 @@ package org.hibernate.orm.test.function.array;
|
|||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hibernate.query.criteria.JpaCriteriaQuery;
|
||||
import org.hibernate.query.criteria.JpaRoot;
|
||||
|
@ -17,6 +18,7 @@ import org.hibernate.testing.jdbc.SharedDriverManagerTypeCacheClearingIntegrator
|
|||
import org.hibernate.testing.orm.junit.BootstrapServiceRegistry;
|
||||
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.Jira;
|
||||
import org.hibernate.testing.orm.junit.RequiresDialectFeature;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||
|
@ -85,6 +87,15 @@ public class ArrayPositionTest {
|
|||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
@Jira("https://hibernate.atlassian.net/browse/HHH-17801")
|
||||
public void testEnumPosition(SessionFactoryScope scope) {
|
||||
scope.inSession( em -> {
|
||||
em.createQuery( "from EntityWithArrays e where array_position(e.theLabels, e.theLabel) > 0", EntityWithArrays.class )
|
||||
.getResultList();
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNodeBuilderArray(SessionFactoryScope scope) {
|
||||
scope.inSession( em -> {
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
package org.hibernate.orm.test.function.array;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
|
@ -24,6 +25,12 @@ public class EntityWithArrays {
|
|||
@Column(name = "the_array", insertable = false, updatable = false)
|
||||
private List<String> theCollection;
|
||||
|
||||
@Column(name = "the_label")
|
||||
private Label theLabel;
|
||||
|
||||
@Column(name = "the_labels")
|
||||
private Set<Label> theLabels;
|
||||
|
||||
public EntityWithArrays() {
|
||||
}
|
||||
|
||||
|
@ -55,4 +62,12 @@ public class EntityWithArrays {
|
|||
public void setTheCollection(List<String> theCollection) {
|
||||
this.theCollection = theCollection;
|
||||
}
|
||||
|
||||
public Set<Label> getTheLabels() {
|
||||
return theLabels;
|
||||
}
|
||||
|
||||
public void setTheLabels(Set<Label> theLabels) {
|
||||
this.theLabels = theLabels;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
|
||||
package org.hibernate.orm.test.function.array;
|
||||
|
||||
public enum Label {
|
||||
A,
|
||||
B,
|
||||
C
|
||||
}
|
Loading…
Reference in New Issue