eclipse / jnosql

Eclipse JNoSQL is a framework which has the goal to help Java developers to create Jakarta EE applications with NoSQL.
Other
231 stars 72 forks source link

Fix record conversion when #384

Closed otaviojava closed 1 year ago

otaviojava commented 1 year ago

Change

Give a record:

@Entity
public record Car(@Id Long plate, @Column("model") String model,
                  @Column("manufacturer") String manufacturer,
                  @Column("year") int year) {
}

When databases change a field or an ID in an insert operation, the current behavior changes the ID directly it works fine if an entity, but it does not work with a record.

@Inject
private Template template;
....
Car car = new Car(null, "SF90", "Ferrari", 2023);
Car updated = template.insert(car);//it will return the same car reference without the id.

This PR verifies if the entity is a record and creates a new instance with all the data from this operation, thus:

@Inject
private Template template;
....
Car car = new Car(null, "SF90", "Ferrari", 2023);
Car updated = template.insert(car);//it from data such as MongoDB or Neo4J with Apache Tinkerpop