In Hibernate 6, a field annotated with @Column @NotNull private Set<String> issueTypeLabels mapped to a Postgres VARCHAR ARRAY column generated:
public static volatile SingularAttribute<TestEntity, Set<String>> issueTypeLabels;
In Hibernate 7 with our without @JdbcTypeCode(SqlTypes.ARRAY) added, the generator produces a raw type:
public static volatile SingularAttribute<TestEntity, Set> issueTypeLabels;
Steps to reproduce: Entity field with @JdbcTypeCode(SqlTypes.ARRAY) and Set<String> type.
Expected: SingularAttribute<TestEntity, Set<String>>
Actual: SingularAttribute<TestEntity, Set> (raw type)
Example:
@MappedSuperclass
public abstract class BaseEntity implements Serializable {
@Id
private UUID id = UUID.randomUUID();
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
}
@Entity
public class TestEntity extends BaseEntity {
@Column
@JdbcTypeCode(SqlTypes.ARRAY)
private Set<String> tags = new HashSet<>();
@Column
private String name;
public Set<String> getTags() {
return tags;
}
public void setTags(Set<String> tags) {
this.tags = tags;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
/**
* Static metamodel for {@link com.example.hibernateissue.TestEntity}
**/
@StaticMetamodel(TestEntity.class)
@Generated("org.hibernate.processor.HibernateProcessor")
public abstract class TestEntity_ extends BaseEntity_ {
/**
* @see #tags
**/
public static final String TAGS = "tags";
/**
* @see #name
**/
public static final String NAME = "name";
/**
* Static metamodel type for {@link com.example.hibernateissue.TestEntity}
**/
public static volatile EntityType<TestEntity> class_;
/**
* Static metamodel for attribute {@link com.example.hibernateissue.TestEntity#tags}
**/
public static volatile SingularAttribute<TestEntity, Set> tags;
/**
* Static metamodel for attribute {@link com.example.hibernateissue.TestEntity#name}
**/
public static volatile SingularAttribute<TestEntity, String> name;
}
plugins {
java
id("org.springframework.boot") version "4.0.6"
id("io.spring.dependency-management") version "1.1.7"
}
group = "com.example"
version = "0.0.1-SNAPSHOT"
description = "hibernate-issue"
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
repositories {
mavenCentral()
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
runtimeOnly("org.postgresql:postgresql")
annotationProcessor("org.hibernate.orm:hibernate-processor")
testImplementation("org.springframework.boot:spring-boot-starter-data-jpa-test")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}
tasks.withType<Test> {
useJUnitPlatform()
}