We're updating the issue view to help you get more done. 

Hibernate OGM causes superfluous update for element collection

Description

I notices when I use @ElementCollection the entity will be persisted without the list and the list will be set afterwards with an extra update.

Due to the fact the list is embedded I would expect it to be saved within the first insert.

1 2 3 4 5 6 @Entity @Table(name = "logs") public class LogEntry { ... @ElementCollection(fetch = FetchType.EAGER) private List<String> subsystems;

Log Output:
save: ogm-eval.logs { "_id" : "eventId" , "logTimestamp" : "2016/01/21 11:56:04:686 +0100" , "systemData" : { "eventType" : "READ" , "systemId" : "SERVICEBUS-NODE1"} , "version" : 0}
<- note subsystems omitted!

update: ogm-eval.logs { "_id" : "eventId"} { "$set" : { "subsystems" : [ "PAYMENT" , "DEBIT"]}}
<- this update comes afterwards

So for one insert two queries are generated which is a performance concern!

Code snippet is straightforward:

1 2 3 LogEntry entry = new LogEntry(); entry.setSubsystems(Arrays.asList("PAYMENT", "DEBIT")); em.persist(entry);

Environment

Wildfly 9.0.2

Status

Assignee

Guillaume Smet

Reporter

Markus Dorner

Labels

None

Worked in

None

Feedback Requested

None

Feedback Requested By

None

backPortable

None

Community Help Wanted

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

backportReEvaluate

None

Components

Sprint

Fix versions

Affects versions

4.2.0.Final

Priority

Major