JPA Hibernate want lazy load to return empty collection

给你一囗甜甜゛ 提交于 2019-12-02 03:56:15

i stumbled over this blog: https://sites.google.com/a/pintailconsultingllc.com/java/hibernate-extra-lazy-collection-fetching

  1. i'm not sure if the LazyCollectionOption.EXTRA is the right one for you in this scenario, turn on your sql-logging to see what queries are really executed by hibernate
  2. you annotated a Collection getter so this may be applicable for you (from referenced blog) If the class is org.hibernate.collection.PersistentBag, you're using bag semantics and now the collection will eager load all the items the first time you touch any item in the List.
  3. i wouldn't use ObjectOutputStream in scenarios where it is possible that client and server are upgraded at different times (android class version vs. server class version). you will safe yourself a lot of trouble with these kinds of problems if you serialize to xml or json. For example with xstream (do not use default xstream-xml serialization though because it contains the whole class-name, use aliases) you can tell the serializer which fields to ignore via annotation or explicity before serializing.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!