Class AbstractSetType<T>
java.lang.Object
com.broadleafcommerce.common.jpa.usertype.AbstractSetType<T>
- Type Parameters:
T- The type of the set elements
- All Implemented Interfaces:
org.hibernate.usertype.EnhancedUserType<Set<T>>,org.hibernate.usertype.UserType<Set<T>>
- Direct Known Subclasses:
InitializingStringSetType,StringSetType
public class AbstractSetType<T>
extends Object
implements org.hibernate.usertype.EnhancedUserType<Set<T>>
A Hibernate
UserType for Sets that need conversion to/from Json. In the past,
this has been handed with a JPA converter, but as of Hibernate 6, Sets are handled
differently with conversion happening on the individual constituents, instead of the entire
Set. This was causing issues with type discovery and conversion based on design
expectations. Changing this case to a Hibernate UserType instead works around the issue,
and returns the behavior for this type of field handling to what it was previously.-
Constructor Summary
ConstructorsConstructorDescriptionAbstractSetType(Class<?> elementType, com.fasterxml.jackson.databind.ObjectMapper objectMapper) AbstractSetType(Class<?> elementType, com.fasterxml.jackson.databind.ObjectMapper objectMapper, boolean initIfNull) -
Method Summary
Modifier and TypeMethodDescriptionassemble(Serializable cached, Object owner) disassemble(Set<T> value) booleanfromStringValue(CharSequence sequence) protected StringintintbooleannullSafeGet(ResultSet rs, int position, org.hibernate.engine.spi.SharedSessionContractImplementor session, Object owner) voidnullSafeSet(PreparedStatement st, Set<T> value, int index, org.hibernate.engine.spi.SharedSessionContractImplementor session) toSqlLiteral(Set<T> value) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.hibernate.usertype.UserType
getDefaultSqlLength, getDefaultSqlPrecision, getDefaultSqlScale, getJdbcType, getValueConverter, replace
-
Constructor Details
-
Method Details
-
getSqlType
public int getSqlType()- Specified by:
getSqlTypein interfaceorg.hibernate.usertype.UserType<T>
-
returnedClass
- Specified by:
returnedClassin interfaceorg.hibernate.usertype.UserType<T>
-
equals
- Specified by:
equalsin interfaceorg.hibernate.usertype.UserType<T>
-
hashCode
- Specified by:
hashCodein interfaceorg.hibernate.usertype.UserType<T>
-
toSqlLiteral
- Specified by:
toSqlLiteralin interfaceorg.hibernate.usertype.EnhancedUserType<T>
-
toString
- Specified by:
toStringin interfaceorg.hibernate.usertype.EnhancedUserType<T>- Throws:
org.hibernate.HibernateException
-
deepCopy
- Specified by:
deepCopyin interfaceorg.hibernate.usertype.UserType<T>
-
disassemble
- Specified by:
disassemblein interfaceorg.hibernate.usertype.UserType<T>
-
isMutable
public boolean isMutable()- Specified by:
isMutablein interfaceorg.hibernate.usertype.UserType<T>
-
fromStringValue
- Specified by:
fromStringValuein interfaceorg.hibernate.usertype.EnhancedUserType<T>- Throws:
org.hibernate.HibernateException
-
assemble
- Specified by:
assemblein interfaceorg.hibernate.usertype.UserType<T>
-
getJson
-