Hi, first of all thanks for your fast reply.
Yes, probably these are methods. I must admit I have no idea how could they be added to already-declared types in run-time (never seen such approche before).
Here's my class:
public class User implements Serializable {
private Long id;
private LoginInfo loginInfo;
private UserSettings userSettings;
private Activity regActivity ,
lastActivity;
private Profile profile;
private List<Comment> comments = new ArrayList<>();
public User(){
} // here the usual getters/setters (auto-generated)
The LoginInfo class contains just 2 fields (String eMail & password with relevant getters/setters)
RESTful service class:
@Path("/user")
public class rs1 {
@SuppressWarnings("unused")
@Context private UriInfo context;
@Context HttpServletRequest request;
@Inject private DAO<User> userDao;
public rs1() {
}
// ....
@PUT
@Consumes("application/json")
@Produces("application/json")
@Path("/reguser")
public Response regUser(LoginInfo loginInfo, @QueryParam("screenX") Integer x,@QueryParam("screenY") Integer y,
@QueryParam("u_id") String u_id){
User user = new User();
user.setLoginInfo(loginInfo);
// setting some other params for user (nothing special)
userDao.persist(user);
return Response.status(200).entity(user).build();
The request is of PUT method with appropriate content-type header of application/json and returns json data, but it has all these "hidden" entrys:
{
"comments":
[
],
"comments__odbHidden":
[
],
"id": 48,
"id__odbHidden": 48,
"lastActivity":
{
"IP": "127.0.0.1",
"date": "2015-10-30T17:25:55.359+03:00",
"ua": "Mozilla/5.0 (Windows NT 5.1; rv:15.0) Gecko/20100101 Firefox/15.0",
"url": "user/reguser"
},
"lastActivity__odbHidden":
{
"IP": "127.0.0.1",
"date": "2015-10-30T17:25:55.359+03:00",
"ua": "Mozilla/5.0 (Windows NT 5.1; rv:15.0) Gecko/20100101 Firefox/15.0",
"url": "user/reguser"
},
"loginInfo":
{
"eMail": "[email protected]",
"password": "somepass"
},
"loginInfo__odbHidden":
{
"eMail": "[email protected]",
"password": "somepass"
},
"profile":
{
},
"profile__odbHidden":
{
},
"regActivity":
{
"IP": "127.0.0.1",
"date": "2015-10-30T17:25:55.359+03:00",
"ua": "Mozilla/5.0 (Windows NT 5.1; rv:15.0) Gecko/20100101 Firefox/15.0",
"url": "user/reguser"
}, // and so on
So the problem is clear I guess.
Must add that I am using the Glassfish server 4. I didn't somehow configure JAX-RS implementation thus using built-in jersey one.
The basic idea of excluding elements, as I know and as google suggest, is annotating needed element with @Xmltransient, but here it doesn't work for an obviouse reason.
This seems even more odd since when I previously used gson to serialize my entities and everything was fine, but I wanted to delegate serialization to the built-in mechanism.