简体   繁体   English

使用SOAP的惰性Hibernate JPA

[英]Lazy Hibernate JPA using SOAP

I have a bunch of annotated, interrelated POJOs that I want to create/modify/search over SOAP. 我有一堆要相互关联的带注释的POJO,我想通过SOAP创建/修改/搜索。 I made a utility to eagerly load every detail of each POJO and create an XML string so I can send the entire POJO graph as a search result. 我制作了一个实用程序来急切地加载每个POJO的每个细节并创建XML字符串,这样我就可以将整个POJO图发送为搜索结果。 Even though the graphs are very small (less than three nodes), the eager loading took a very long time (500ms/node). 即使图很小(少于三个节点),急切的加载也花费了很长时间(500ms /节点)。

It seems like the bottleneck is having to eager the entire graph of each node. 似乎瓶颈必须渴望每个节点的整个图。 Is it somehow possible to just lazy load over SOAP? 是否可以通过SOAP延迟加载? What are some other alternatives? 还有哪些其他选择?

It is possible to lazy load over SOAP, but it's rather involved. 可以通过SOAP进行延迟加载,但这涉及到。 And it most definitely won't be faster :-) 它绝对不会更快:-)

Basically, you'll need to create proxies for your POJOs (using bytecode instrumentation) that will know how to load full object (or its individual property if you want to get down to that level) over SOAP. 基本上,您将需要为POJO(使用字节码工具)创建代理,这些代理将知道如何通过SOAP加载完整的对象(如果希望降至该级别,则可以加载其单个属性)。 If that sounds like repeating what Hibernate does, it's because it is :-) This approach only makes sense when the "remotely-lazy" properties are not likely to be accessed by the client that often AND are really expensive to eagerly load to begin with. 如果这听起来像是在重复Hibernate的操作,那是因为它是:-)这种方法仅在客户端不太可能经常访问“远程”属性并且急于加载时非常昂贵时才有意义。 。

Another possible approach is to add "inflation level" parameter to your SOAP API calls, something along the lines of SELF (direct properties only) / CHILDREN (direct children) / FULL (full object tree), which would cause only appropriate properties to be initialized. 另一种可能的方法是在您的SOAP API调用中添加“通胀级别”参数,类似于SELF(仅直接属性)/ CHILDREN(直接子级)/ FULL(完整对象树)的类,这将导致仅适当的属性为初始化。 That delegates responsibility for obtaining properly inflated object to the client (which presumably knows what it needs to work with). 这将负责获得适当膨胀的对象的责任委托给客户端(假定客户端知道需要使用什么对象)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM