You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomee.apache.org by DonatasCiuksys <do...@gmail.com> on 2017/04/12 18:39:36 UTC

Annotations @JsonbTransient and @JohnzonIgnore do not work

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.

Re: Annotations @JsonbTransient and @JohnzonIgnore do not work

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Le 12 avr. 2017 21:01, "DonatasCiuksys" <do...@gmail.com> 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.

Re: Annotations @JsonbTransient and @JohnzonIgnore do not work

Posted by DonatasCiuksys <do...@gmail.com>.
    > 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?




--
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.

Re: Annotations @JsonbTransient and @JohnzonIgnore do not work

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi

Which config do you use for the access mode?

Which version also?


Le 12 avr. 2017 20:49, "DonatasCiuksys" <do...@gmail.com> 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.