Open rcbandit111 opened 1 year ago
it looks like this project has been abandoned.
I recently finished migrating my project to Hibernate 6. You have a couple of options:
java.time.OffsetDateTime
instead of DateTime
DateTime
Something like this:
public class DateTimeJavaType extends AbstractClassJavaType<DateTime> {
public static final DateTimeJavaType INSTANCE = new DateTimeJavaType();
public DateTimeJavaType() {
super(DateTime.class, ImmutableMutabilityPlan.INSTANCE);
}
@Override
public <X> X unwrap(DateTime value, Class<X> type, WrapperOptions options) {
if (value == null) {
return null;
}
if (DateTime.class.isAssignableFrom(type)) {
return (X) value;
}
if (Timestamp.class.isAssignableFrom(type)) {
return (X) new Timestamp(value.toDate().getTime());
}
throw unknownUnwrap(type);
}
@Override
public <X> DateTime wrap(X value, WrapperOptions options) {
if (value == null) {
return null;
}
if (value instanceof Timestamp) {
return new DateTime(value);
}
if (value instanceof DateTime) {
return (DateTime) value;
}
throw unknownWrap(value.getClass());
}
@Override
public JdbcType getRecommendedJdbcType(JdbcTypeIndicators indicators) {
return indicators.getTypeConfiguration()
.getJdbcTypeRegistry()
.getDescriptor(Types.TIMESTAMP);
}
}
Then you can use it like this:
@JavaType(DateTimeJavaType.class)
private DateTime until;
@theigl Thanks for the reply. Using java.time.OffsetDateTime
looks good enough. Any issues that I might face?
I have the similar problem, but it's about currency mapping:
@Type(type = "org.jadira.usertype.moneyandcurrency.joda.PersistentMoneyAmount")
private Money fee;
anyone gets any idea to work around this?
I use 'org.jadira.usertype:usertype.core:7.0.0.CR1' into my project. I want to migrate to Java 17. I have the following columns definitions:
Do you know how I can replace the code for latest Java 17/Hibernate/Spring Boot?