users@jersey.java.net

[Jersey] Re: jersey-server-linking chases object references in entities

From: Jakub Podlesak <jakub.podlesak_at_oracle.com>
Date: Mon, 11 Jul 2011 17:13:02 +0200

Hi Daniel,

You are right. Currently there is no way to disable member field
reference processing. But that should be easy to implement using a special
resource configuration feature in an "all or nothing manner".

Would that be something helpful for your use-case?
Or if what you need is a "smarter" approach, could you please
try to elaborate on how to distinguish the "to be followed" references
from the rest?

~Jakub

On 07/06/2011 03:39 PM, Daniel Larsson wrote:
> Tried out jersey-server-linking a bit, and noticed the RefProcessor
> recursively chases object references in the entity object, trying to
> find @Link annotations. This is causing a bit of a problem for me.
> Part of the returned entity is a JPA entity bean, where I've filtered
> out certain properties (don't want to send the transitive closure of
> the object graph back as JSON, so I'm typically marking object
> references with @XmlTransient, and adding properties returning URIs
> instead, which are included in the JSON output). But since the JPA
> entity is part of the Jersey Response entity, *every* object reference
> is chased, causing tons of SQL queries to be performed, to bring in
> those objects into memory. Not fun. I couldn't see a way to influence
> the reference chasing, is this correct? In other words, I will need to
> make a proxy for the JPA entity, only exposing the subset of the JPA
> bean properties I actually want to serialize, yes?
>
> Thanks in advance,
>
> Daniel Larsson