简体   繁体   中英

Lazy Hibernate JPA using SOAP

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

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?

It is possible to lazy load over SOAP, but it's rather involved. 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. 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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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