使用SOAP的懒惰Hibernate JPA [英] Lazy Hibernate JPA using SOAP

查看:143
本文介绍了使用SOAP的懒惰Hibernate JPA的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一堆注释的,相互关联的POJO,我想通过SOAP创建/修改/搜索。我制作了一个实用程序,用于加载每个POJO的每个细节并创建一个XML字符串,以便将整个POJO图形作为搜索结果发送。即使图形非常小(少于三个节点),热切加载花费很长时间(500ms /节点)。

I have a bunch of annotated, interrelated POJOs that I want to create/modify/search over 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. Even though the graphs are very small (less than three nodes), the eager loading took a very long time (500ms/node).

看起来像是瓶颈渴望每个节点的整个图形。是否有可能通过SOAP延迟加载?什么是其他的选择?

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? What are some other alternatives?

推荐答案

有可能通过SOAP进行延迟加载,但它是相当复杂的。而且它绝对不会更快: - )

It is possible to lazy load over SOAP, but it's rather involved. And it most definitely won't be faster :-)

基本上,您需要为您的POJO创建代理(使用字节码工具),以便知道如何加载完整的对象(或其个人财产,如果你想要达到那个水平)通过SOAP。如果这听起来像重复Hibernate所做的那样,那是因为它是:-)
这种方法只有在客户端不可能访问远程懒惰属性时才有意义,而这往往是AND 真的昂贵的开始加载。

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. 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.

另一个可能的方法是将通胀水平参数添加到您的SOAP API调用,沿着SELF (仅限直接属性)/ CHILDREN(直接子对象)/ FULL(全对象树),这将只会导致适当的属性被初始化。这代表了向客户获得适当夸大的对象的责任(这大概知道它需要什么工作)。

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. That delegates responsibility for obtaining properly inflated object to the client (which presumably knows what it needs to work with).

这篇关于使用SOAP的懒惰Hibernate JPA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆