Skip to content

Commit

Permalink
fix: convertion to new id
Browse files Browse the repository at this point in the history
Signed-off-by: Otavio Santana <otaviopolianasantana@gmail.com>
  • Loading branch information
otaviojava committed May 19, 2023
1 parent 5eb61ca commit 2663112
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ public DocumentEntity update(DocumentEntity entity) {
.orElseThrow(() -> new IllegalArgumentException("For updates at DocumentEntity"));
try (ODatabaseSession tx = pool.acquire()) {
ODocument record = tx.load(recordId);
entity.remove(RID_FIELD);
entity.remove(ID_FIELD);
entity.remove(VERSION_FIELD);
toMap(entity).forEach(record::field);
tx.save(record);
updateEntity(entity, record);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ static DocumentEntity convert(ODocument document) {
.forEach(entity::add);
entity.add(Document.of(RID_FIELD, document.field(RID_FIELD).toString()));
entity.add(Document.of(VERSION_FIELD, document.getVersion()));
entity.add(Document.of(ID_FIELD, document.field(RID_FIELD).toString()));
return entity;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import jakarta.inject.Inject;
import org.eclipse.jnosql.databases.orientdb.communication.DocumentDatabase;
import org.eclipse.jnosql.databases.orientdb.communication.OrientDBDocumentConfigurations;
import org.eclipse.jnosql.databases.orientdb.mapping.OrientDBTemplate;
import org.eclipse.jnosql.mapping.Convert;
import org.eclipse.jnosql.mapping.config.MappingConfigurations;
Expand All @@ -31,6 +32,7 @@

import java.util.Optional;

import static com.orientechnologies.orient.core.db.ODatabaseType.PLOCAL;
import static java.util.UUID.randomUUID;
import static org.assertj.core.api.Assertions.assertThat;
import static org.eclipse.jnosql.communication.driver.IntegrationTest.MATCHES;
Expand All @@ -50,7 +52,11 @@ class OrientDBTemplateIntegrationTest {

static {
DocumentDatabase.INSTANCE.get("library");
System.setProperty(MappingConfigurations.DOCUMENT_DATABASE.get(), "library");
System.setProperty(MappingConfigurations.DOCUMENT_DATABASE.get(), "jnosql");
System.setProperty(OrientDBDocumentConfigurations.HOST.get(), "/tmp/db/");
System.setProperty(OrientDBDocumentConfigurations.USER.get(), "root");
System.setProperty(OrientDBDocumentConfigurations.PASSWORD.get(), "rootpwd");
System.setProperty(OrientDBDocumentConfigurations.STORAGE_TYPE.get(), PLOCAL.toString());
}
@Test
public void shouldInsert() {
Expand Down

0 comments on commit 2663112

Please sign in to comment.