OpenNTF / org.openntf.xsp.jakartaee

XPages Jakarta EE support libraries
Apache License 2.0
21 stars 7 forks source link

NoSQL repositories/methods seem to sometimes mix types #183

Open jesse-gallagher opened 2 years ago

jesse-gallagher commented 2 years ago

This is something I observed in a side app, and I see it now when working on adding database qualifiers. For example:

public interface PersonRepository extends Repository<Person, String> {
    Stream<Person> findAll();
}

and:

public interface OtherPersonRepository extends Repository<OtherPerson, String> {
    Stream<OtherPerson> findAll();
}

Somehow, they will end up both producing the same objects, leading to ClassCastExceptions and mixed data. I don't remember seeing this when I first worked with JNoSQL, so it's possible that it's due to a subsequent change (perhaps caching classes without proper unique keys) or something specific to Domino.

jesse-gallagher commented 2 years ago

At least some of the trouble seems to be due to the fact that both of these documents use the form "Person", and that becomes the identifier for the Entity. While unfortunate, it makes sense that this would be an illegal state, and it'd probably be worth investigating adding another custom annotation to define when the form should be distinct from the entity name.

I think I saw this when the entity name was different, though, so this may also be a problem on its own still.

jesse-gallagher commented 2 years ago

In the case of the "special annotation to specify the form", it'd probably be good to make that generalizable into specifying a DQL query to limit matched docs. This would allow for different entities to match documents of the same form but with different distinguishing characteristics.