dev@jersey.java.net

Using Jersey Client With Entity Inheritance

From: Mike Rother <mjrother_snowshoe_at_yahoo.com>
Date: Mon, 7 Jun 2010 17:02:48 -0700 (PDT)

I am trying
to return entities that all are in the same class hierarchy.
BaseTestClass,
Subclass1TestClass (extends BaseTestClass) and SubClass2TestClass (extends
BaseTestClass).
 
I see the
xml response contains the XML for the correct entity class @XmlRootElement(). How
do I have the Jersey client know how to parse
the response to the correct entities?
 
When I try
this:
            BaseTestClass result =
res.type(MediaType.APPLICATION_JSON).get(new GenericType< BaseTestClass>()
{});
 
I get an
instance of the BaseTestClass and not the subclass as desired. How can I get an
instance or a list of instance of the correct classes?