Skip to content

Commit

Permalink
Fix for #1032 (#1033)
Browse files Browse the repository at this point in the history
* fix for #1032

* Update CHANGELOG.md
  • Loading branch information
anidotnet authored Aug 31, 2024
1 parent 7e30039 commit a6c0143
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

- Fix for `Document.getFields()` not returning iterable fields
- Fix for failing tests on systems with non-ENGLISH locale #994
- Fix for NPE in `DefaultTransactionalRepository` #1032

## Release 4.3.0 - Jul 1, 2024

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public void clear() {

@Override
public Cursor<T> find(Filter filter, FindOptions findOptions) {
return operations.find(filter, findOptions, type);
return operations.find(filter, findOptions, getType());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,26 @@
import com.github.javafaker.Faker;
import lombok.extern.slf4j.Slf4j;
import org.dizitart.no2.collection.Document;
import org.dizitart.no2.collection.FindOptions;
import org.dizitart.no2.collection.NitriteCollection;
import org.dizitart.no2.common.meta.Attributes;
import org.dizitart.no2.exceptions.NitriteIOException;
import org.dizitart.no2.exceptions.TransactionException;
import org.dizitart.no2.index.IndexType;
import org.dizitart.no2.integration.repository.BaseObjectRepositoryTest;
import org.dizitart.no2.repository.ObjectRepository;
import org.dizitart.no2.integration.repository.data.SubEmployee;
import org.dizitart.no2.integration.repository.decorator.Manufacturer;
import org.dizitart.no2.integration.repository.decorator.ManufacturerDecorator;
import org.dizitart.no2.repository.Cursor;
import org.dizitart.no2.repository.ObjectRepository;
import org.dizitart.no2.transaction.Session;
import org.dizitart.no2.transaction.Transaction;
import org.junit.Test;

import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
Expand Down Expand Up @@ -824,4 +831,28 @@ public void testFailureOnClosedTransaction() {
fail();
}
}

@Test
public void testWithEntityDecorator() {
ObjectRepository<Manufacturer> repo = db.getRepository(new ManufacturerDecorator());
try (Session session = db.createSession()) {
try (Transaction transaction = session.beginTransaction()) {
ObjectRepository<Manufacturer> txRepo = transaction.getRepository(new ManufacturerDecorator());
Manufacturer manufacturer = new Manufacturer();
manufacturer.setName("John");
manufacturer.setAddress("1234");
manufacturer.setUniqueId(1);
txRepo.insert(manufacturer);

Cursor<Manufacturer> cursor = txRepo.find(where("name").eq("John"), FindOptions.limitBy(1));
for (Manufacturer item : cursor) {
assertEquals(item.getName(), "John");
}

transaction.commit();
}
}
Cursor<Manufacturer> cursor = repo.find(where("name").eq("John"), FindOptions.limitBy(1));
assertEquals(cursor.size(), 1);
}
}

0 comments on commit a6c0143

Please sign in to comment.