N
N
Nikolai Gerasimov2016-10-06 08:48:09
Java
Nikolai Gerasimov, 2016-10-06 08:48:09

Detach One To One entity. Or is it possible not to save the OneToOne entity?

There is an entity-class Examination, it contains a link to another entity - ExaminationResult.

@Entity
@Table(name = "EXAMINATIONS")
public class Examination{
/***/

@OneToOne(mappedBy = "examination", cascade = {CascadeType.PERSIST, CascadeType.REFRESH, CascadeType.MERGE, CascadeType.DETACH})
    private ExaminationResult examinationResult;

/***/
}

How can I make it so that when the entityManager.merge(examination); to update only examination, and not to change examinationResult in the database, but at the same time, during other operations (persist, remove, etc.), were operations with examinationResult performed?
More specifically, entityManager.merge(examination); is called in several methods, and only in one it is not necessary to update the examinationResult, in all the rest it is necessary.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question