Home JPA @Convert in @Embeddable triggers unnecessary delete insert
Reply: 0

JPA @Convert in @Embeddable triggers unnecessary delete insert

SetNug
1#
SetNug Published in 2018-01-11 08:20:02Z

We have the following JPA entities:

@Entity
@Table(name = "T_PRIZE")
public final class Prize
{   
    @Id
    @Column(updatable = false)
    private long id;

    @Embedded
    private Target target;
}

@Embeddable
public final class Target
{   
    @ElementCollection
    @CollectionTable(name = "T_CUTOFF", joinColumns = @JoinColumn(name = "PRIZE_ID"))
    private List<CutOff> cutOffs = new LinkedList<CutOff>();

}

@Embeddable
public final class CutOff implements Serializable
{
    @Convert(converter = PenaltiesConverter.class)
    private List<IPenalty> penalties;
}

With above configuration we find so many delete-inserts on table T_CUTOFF even if we don't touch Prize entity. Even simple native 'select SEQ.nextval from DUAL' will trigger delete-insert.

This behavior leads to intermittent bugs in our app where updates to the CutOff entity seems to be not persisted in DB, but it turns out that another thread performs delete-insert on the same table afterwards.

If we remove the @Convert field than the unnecessary delete-inserts no longer happen.

We're aware of JPA auto flush feature, but is this the expected behavior with @Convert in @Embeddable ?

Any help would be greatly appreciated.

Thanks & Regards,

Michal

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.316643 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO