0

I have an entity Ticket.class that has the following properties (amongst others):

@OneToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE})
private List<Comment> comments;

@Transient
private Comment comment;

I then have a method as follows:

public void edit() {
    ...
    // Add the comment
    comments.add(comment);
    comment = new Comment();

    // Persist the ticket
    em.merge(ticket);
}

The problem I am facing is that when I next retrieve the Ticket from the DB the @Transient value is present and set to the last comment. This must be coming from a cache but I can't figure out where or how to flush it other than by restarting the server.

tarka
  • 5,289
  • 10
  • 51
  • 75

1 Answers1

0

Have you flush your entity before merge. try

 em.flush()

there might be possiblity that entity has not sysnchronize with database.

Sai prateek
  • 11,842
  • 9
  • 51
  • 66