Consider a standard java entity BarEntity
declaring a OneToMany relation to Set<FooEntity> fooEntities
.
I would like to replace the Set<FooEntitty>
with a guava ForwardingSet
, giving me the freedom to enrich the default set with some business logic (summing, filtering, sorting, ...)
However, when I replace the Set<FooEntity>
with MyFooEntities
, I get .springframework.orm.jpa.JpaSystemException: Could not set value of type [.hibernate.collection.spi.PersistentSet]:
MyFooEntities
extends the ForwardingSet<FooEntity>
and provides a delegate as well as a no-args constructor.
The OneToMany annotation contains the targetEntity = FooEntity.class
definition. I also tried to use a @Convert
annotation pointing to a custom AttributeConverter
that constructs MyFooEntities
via Set<FooEntity>
and returns the delegate()
set encapsulated in my forwarding set.
Is it possible to use a forwardingSet (or any custom set impl) in OneToMany mappings? If so: how?