Annotations @JsonbTransient and @JohnzonIgnore do not work

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Annotations @JsonbTransient and @JohnzonIgnore do not work

DonatasCiuksys
I have JPA entity class Student and simple REST service (see code bellow). Note that I have annotated @ManyToMany field with @JsonbTransient and @JohnzonIgnore annotations (because it courses infinite loop during serialization to JSON).
Yet this doesn't help, TomEE tries to convert this ManyToMany field to JSON and fails because of cyclic dependencies.

It seems either we have a regression (https://issues.apache.org/jira/browse/JOHNZON-68) or some misconfiguration.

@ApplicationScoped
@Path("/student")
@Produces(MediaType.APPLICATION_JSON)
public class StudentRestService {

    @Inject private EntityManager em;

    @GET
    @Path("/{studentId}")
    @Transactional
    public Student find(@PathParam("studentId") Integer studentId) {
        return em.find(Student.class, studentId);
    }
}


@Entity
@Getter
@Setter
@EqualsAndHashCode(of = "registrationNo")
@ToString(of = {"id", "firstName", "lastName", "registrationNo"})
public class Student implements Serializable {
    ...

    @ManyToMany
    @JsonbTransient
    @JohnzonIgnore
    private List<Course> courseList = new ArrayList<>();
}
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Annotations @JsonbTransient and @JohnzonIgnore do not work

Romain Manni-Bucau
Ps: jsonb is not supported if you dont add and activate jsonb module cause
it is only ee 8

Le 12 avr. 2017 20:56, a écrit :

Hi

Which config do you use for the access mode?

Which version also?


Le 12 avr. 2017 20:49, "DonatasCiuksys" <[hidden email]> a
écrit :

I have JPA entity class Student and simple REST service (see code bellow).
Note that I have annotated @ManyToMany field with @JsonbTransient and
@JohnzonIgnore annotations (because it courses infinite loop during
serialization to JSON).
Yet this doesn't help, TomEE tries to convert this ManyToMany field to JSON
and fails because of cyclic dependencies.

It seems either we have a regression (
https://issues.apache.org/jira/browse/JOHNZON-68
<https://issues.apache.org/jira/browse/JOHNZON-68>  ) or some
misconfiguration.

@ApplicationScoped
@Path("/student")
@Produces(MediaType.APPLICATION_JSON)
public class StudentRestService {

    @Inject private EntityManager em;

    @GET
    @Path("/{studentId}")
    @Transactional
    public Student find(@PathParam("studentId") Integer studentId) {
        return em.find(Student.class, studentId);
    }
}


@Entity
@Getter
@Setter
@EqualsAndHashCode(of = "registrationNo")
@ToString(of = {"id", "firstName", "lastName", "registrationNo"})
public class Student implements Serializable {
    ...

    @ManyToMany
    @JsonbTransient
    @JohnzonIgnore
    private List<Course> courseList = new ArrayList<>();
}



--
View this message in context: http://tomee-openejb.979440.
n4.nabble.com/Annotations-JsonbTransient-and-JohnzonIgnore-do-not-work-
tp4681537.html
Sent from the TomEE Dev mailing list archive at Nabble.com.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Annotations @JsonbTransient and @JohnzonIgnore do not work

Romain Manni-Bucau
In reply to this post by DonatasCiuksys
Hi

Which config do you use for the access mode?

Which version also?


Le 12 avr. 2017 20:49, "DonatasCiuksys" <[hidden email]> a
écrit :

I have JPA entity class Student and simple REST service (see code bellow).
Note that I have annotated @ManyToMany field with @JsonbTransient and
@JohnzonIgnore annotations (because it courses infinite loop during
serialization to JSON).
Yet this doesn't help, TomEE tries to convert this ManyToMany field to JSON
and fails because of cyclic dependencies.

It seems either we have a regression (
https://issues.apache.org/jira/browse/JOHNZON-68
<https://issues.apache.org/jira/browse/JOHNZON-68>  ) or some
misconfiguration.

@ApplicationScoped
@Path("/student")
@Produces(MediaType.APPLICATION_JSON)
public class StudentRestService {

    @Inject private EntityManager em;

    @GET
    @Path("/{studentId}")
    @Transactional
    public Student find(@PathParam("studentId") Integer studentId) {
        return em.find(Student.class, studentId);
    }
}


@Entity
@Getter
@Setter
@EqualsAndHashCode(of = "registrationNo")
@ToString(of = {"id", "firstName", "lastName", "registrationNo"})
public class Student implements Serializable {
    ...

    @ManyToMany
    @JsonbTransient
    @JohnzonIgnore
    private List<Course> courseList = new ArrayList<>();
}



--
View this message in context: http://tomee-openejb.979440.
n4.nabble.com/Annotations-JsonbTransient-and-JohnzonIgnore-do-not-work-
tp4681537.html
Sent from the TomEE Dev mailing list archive at Nabble.com.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Annotations @JsonbTransient and @JohnzonIgnore do not work

DonatasCiuksys
    > Which config do you use for the access mode? Which version also?

No explicit config. TomEE 7.0.3 WebProfile.

    > jsonb is not supported if you dont add and activate jsonb module

How to do this?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Annotations @JsonbTransient and @JohnzonIgnore do not work

Romain Manni-Bucau
Le 12 avr. 2017 21:01, "DonatasCiuksys" <[hidden email]> a
écrit :

    > Which config do you use for the access mode? Which version also?

No explicit config. TomEE 7.0.3 WebProfile.



Maybe try configuring it with access mode field or add the annotation on
the getter.


    > jsonb is not supported if you dont add and activate jsonb module

How to do this?


Add johnzon-jsonb dependency without transitive ones but johnzon mapper is
enough if you are ok using johnzon annotations





--
View this message in context: http://tomee-openejb.979440.
n4.nabble.com/Annotations-JsonbTransient-and-JohnzonIgnore-do-not-work-
tp4681537p4681540.html
Sent from the TomEE Dev mailing list archive at Nabble.com.
Loading...