Recently I have migrate my project from hibernate 5 to 6 We are using a SequenceStyleGenerator to generate sequence for primary key Eg :working in hibernate 5
public class StringPrefixedSequenceIdGenerator extends SequenceStyleGenerator {
public static final String VALUE_PREFIX_PARAMETER = "valuePrefix";
public static final String VALUE_PREFIX_DEFAULT = "";
private String valuePrefix;
public static final String NUMBER_FORMAT_PARAMETER = "numberFormat";
public static final String NUMBER_FORMAT_DEFAULT = "%d";
private String numberFormat;
@Override
public Serializable generate(SharedSessionContractImplementor session,
Object object) throws HibernateException {
return valuePrefix + String.format(numberFormat, super.generate(session, object));
}
@Override
public void configure(Type type, Properties params,
ServiceRegistry serviceRegistry) throws MappingException {
super.configure(LongType.INSTANCE, params, serviceRegistry);
valuePrefix = ConfigurationHelper.getString(VALUE_PREFIX_PARAMETER,
params, VALUE_PREFIX_DEFAULT);
numberFormat = ConfigurationHelper.getString(NUMBER_FORMAT_PARAMETER,
params, NUMBER_FORMAT_DEFAULT);
}
}
But this logic doesn't work in hibernate 6 Because org.hibarnate.type.LongType is deprecated And I can find alternative to this Is any other way to handle the above problem because under org.hibarnate.type most of the types are deprecated And I can find any article on why this classes were removed and alternative |