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
ConstructorDescriptionAbstractSetType
(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) boolean
fromStringValue
(CharSequence sequence) protected String
int
int
boolean
nullSafeGet
(ResultSet rs, int position, org.hibernate.engine.spi.SharedSessionContractImplementor session, Object owner) void
nullSafeSet
(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, wait
Methods inherited from interface org.hibernate.usertype.UserType
getDefaultSqlLength, getDefaultSqlPrecision, getDefaultSqlScale, getJdbcType, getValueConverter, replace
-
Constructor Details
-
Method Details
-
getSqlType
public int getSqlType()- Specified by:
getSqlType
in interfaceorg.hibernate.usertype.UserType<T>
-
returnedClass
- Specified by:
returnedClass
in interfaceorg.hibernate.usertype.UserType<T>
-
equals
- Specified by:
equals
in interfaceorg.hibernate.usertype.UserType<T>
-
hashCode
- Specified by:
hashCode
in interfaceorg.hibernate.usertype.UserType<T>
-
toSqlLiteral
- Specified by:
toSqlLiteral
in interfaceorg.hibernate.usertype.EnhancedUserType<T>
-
toString
- Specified by:
toString
in interfaceorg.hibernate.usertype.EnhancedUserType<T>
- Throws:
org.hibernate.HibernateException
-
deepCopy
- Specified by:
deepCopy
in interfaceorg.hibernate.usertype.UserType<T>
-
disassemble
- Specified by:
disassemble
in interfaceorg.hibernate.usertype.UserType<T>
-
isMutable
public boolean isMutable()- Specified by:
isMutable
in interfaceorg.hibernate.usertype.UserType<T>
-
fromStringValue
- Specified by:
fromStringValue
in interfaceorg.hibernate.usertype.EnhancedUserType<T>
- Throws:
org.hibernate.HibernateException
-
assemble
- Specified by:
assemble
in interfaceorg.hibernate.usertype.UserType<T>
-
getJson
-