Open jwgmeligmeyling opened 5 years ago
Sounds like a goid idea. We can start with the RegularEnumSet and map it to a bigint.
This seems easier to do with the restructuring of the array types in https://github.com/vladmihalcea/hibernate-types/issues/97
I think it's worth investigating, indeed.
I've seen some request before to be able to map an
EnumSet
to a column in Hibernate (for example: https://developer.jboss.org/thread/106544). Currently can map an enum array to aEnum[]
value, but arrays are not as convenient as being able to use the JavaCollection
API. One downside of this approach is that anEnumSet
has set characteristics, wheras an array does not. So it might make more sense to map it to aList
instead. Perhaps we could add support both.Anyways, currently the issue is easily worked around by wrapping and unwrapping the value in the attribute getter and setter. However, it might be a nice inclusion as custom type.
I have quickly played with the idea and it seems we can easily pull this off, somewhat relying on the implementation for
EnumArrayType
. However, there are a few downsides. Because the generic type cannot (supposedly) be determined from theDynamicParameterizedType
parameter values, the enum value class would have to be specified through the@Type
's parameters.@vladmihalcea do you have interest in including this as a feature? And if so, how would you like to see the general structure of such an addition?
I suppose that the type implementation has to be separated from the entire
type.array
package, even though we're dealing with DB arrays, we're not dealing with Java arrays, which is what this package is for. So then I'd personally put it intype.basic
. Also, we might want to setup a type composition structure if we want to support mapping to any ofCollection
,Set
,List
, etc as well.Given a few pointers I can spend some time on implementing this in the foreseeable future.