EnumSet display in sleep mode

How to save EnumSet in a database (using Hibernate)?

@Entity
public class A
{
 public static enum SOME_ENUM { A, B, C };

 private EnumSet<SOME_ENUM> myEnumSet = EnumSet.of(SOME_ENUM.A, SOME_ENUM.B);

 ...
 ...
}

If I try to keep the above, I get an exception, of course. I wanted to use @CollectionOfElements, but it is deprecated. Is there an alternative to @CollectionOfElements?

Is there a way to save EnumSet in a single column without a UserType entry?

Thank!

+3
source share
1 answer

hibernate does not support this support. Please note that when working with hibernation and collections you should really specify only the interface; in this case Set. Hibernate proxies all collections so that it can deal effectively with lazy loading.

This does not mean that it is difficult. See Documentation

https://forum.hibernate.org/viewtopic.php?p=2300843

0

Source: https://habr.com/ru/post/1779776/


All Articles