最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

jpa - Hibernate: OneToMany Mapping with custom guava forwarding set - Stack Overflow

programmeradmin3浏览0评论

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?

发布评论

评论列表(0)

  1. 暂无评论