views:

192

answers:

1

Using @XStreamOmitField in my POJO seems to have no effect whatsoever. the annotated field still gets exposed in the xml or json representation.

@XStreamAlias("Pojo")
@Entity
public class Pojo {
    private String name;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long key;

    @XStreamOmitField
    private String hidden;

    public Pojo(String name, String hidden) {
        this.name = name;
        this.hidden = hidden;
    }
}

and in the ServerResource

@Get
public Pojo test() {
    Pojo pj= new Pojo("hansi","hinter");
    return pj;
}

gets me

<com.myComp.ORMTest.Pojo>
  <name>hansi</name>
  <hidden>hinter</hidden>
</com.myComp.ORMTest.Pojo>

Any ideas why the annotations are ignored?

A: 

Two things come to mind:

1.) Did you tell XStream to parse the annotations?

2.) Does your web framework maybe use proxies to access the pojos and those don't delegate the annotations? (happened to a friend with Apache Tapestry)

Christopher Oezbek
Great leads. Will start digging in that direction.Thanks
chaos0815