After upgrading spring boot version from 2.7 to 3.0 the Hibernate version was also increased to 6. For the field like below I need to create two columns from one field. Hibernate 5 implementation works. I create the two columns in the database SOME_TIME, SOME_TIME_ZONE
The field from the entity
@Type(type = OffsetTimeMyType.TYPE)
@Columns(columns = {
@Column(name = "SOME_TIME", nullable = false),
@Column(name = "SOME_TIME_ZONE", nullable = false)
})
private OffsetTime someTime;
UserType implementation
public class OffsetTimeMyType implements UserType {
public static final String TYPE = "com.package.OffsetTimeMyType";
@Override
public int[] sqlTypes() {
return new int[]{
Types.TIME,
Types.INTEGER
};
}
@Override
public Class returnedClass() {
return OffsetTime.class;
}
.....rest of the methods........
}
Hibernate 6 implementation doesn’t work in my case, because the method sqlTypes doesn’t accept an array anymore. I’m trying to do something similar
The field from the entity
@Type(OffsetTimeMyType.class)
@Columns(columns = {
@Column(name = "SOME_TIME", nullable = false),
@Column(name = "SOME_TIME_ZONE", nullable = false)
})
private OffsetTime someTime;
UserType implementation
public class OffsetTimeMyType implements UserType<OffsetTime> {
@Override
public int getSqlType() {
return SqlTypes.TIME_WITH_TIMEZONE;
}
@Override
public Class returnedClass() {
return OffsetTime.class;
}
.....rest of the methods........
}
I get this error: Property ‘com.package.MyEntity.someTime’ maps to 2 columns but 1 columns are required (type ‘com.package.usertype.OffsetTimeMyType’ spans 1 columns)