It's comforting to have company.

Reading your email, it seems as if what I really need is to use Tatu's
mechanisms in Jackson to serialize a Parent reference as the Parent's ID. I
could do that by coping with hibernate <meta> tags, or by turning off
hibernate Java generation, checking in the classes, and just adding his
annotations. Or I could find out if his JAX-RS providers can be spoken to
about their ObjectMapper objects, to which I think I could give orders for
this purpose.

Just dropping names won't help me. I need to map back and forth to Ids. On
the serialization side, one would think that a jaxb customization would be
easy, but coming back the other way I'd need to map the integer ID to the
reference, if I don't want hibernate databasing my pants off, I don't know
what I need.

For now I've eliminated the <many-to-one/> items from hibernate, and made
the classes just store the integer ids, since I don't have any really strong
need for the object references at all.

On Wed, Oct 14, 2009 at 8:37 AM, Sergey Beryozkin <[email protected]>wrote:

> Hi Benson
>
> It appears to be quite a common query.
> I think, ultimately, JBoss JAXB introductions could be of help but
> apprently they don't support dynamic proxies for 'XmlTransient.
> What I'm working upon in the background is for letting users to specify, by
> listing a list of names (possibly fully qualified) which have to be dropped,
> as a property on (default) JAXB/JSOn providers.
> So the intermediate option is to register a custom JSONProvider which
> extends the one we ship and which overrides
>
> getStreamWriter() method, which will return a custom writer configured to
> drop everything in Parent but its id.
>
> I'm not sure how efficient it can be with hibernate, that is I'm not sure
> if blocking at the XMlStreamWriter level will prevent JAXB/hibernate from
> executing futile db queries under the hood
> Give it a try though please, I'd be interested to know if it helps
>
> Sergey
>
>
>
>  Starting from hibernate, I seem to have engineered myself into a small
>> corner.
>>
>> class Parent {
>>  int id; // public property fcns available
>> };
>>
>> class Child {
>>  int id;
>> Parent parent;
>> };
>>
>> What I want in the JSON is the parent's ID, not an entire dump of the
>> parent. Using jackson, there might be an annotation to fix this, but since
>> the java is generated by hibernate, and the doc on this area in hibernate
>> is
>> awful, I don't much want to go there. There's nothing generic to JAX-RS
>> for
>> dealing with this, is there?
>>
>>
>

Reply via email to