-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom Repository methods #460
Comments
There are a few ways to go about it: You should be able to use the You can also use the @Inject @Database(value=DatabaseType.DOCUMENT, provider="optionalRepoName")
private DominoTemplate template Then, you can perform a query like: DocumentQuery query = DocumentQuery.builder().from("Project").where(DocumentCondition.eq("Owner", userInfo.getName())).build();
Stream<Project> projects = template.select(query); |
Thanks for the answer, Jesse. Basically, this is a good idea but I would like to have these functions in a generic base interface/class which doesn't know anything about which tables to use. import java.util.stream.Stream;
import org.openntf.xsp.nosql.mapping.extension.DominoRepository;
public interface CommonDominoDocumentRepository<T> extends DominoRepository<T, String> {
public Stream<T> findAll();
} public interface ArtistRepository extends CommonDominoDocumentRepository<Artist> {
} If I would use the approach with the Database injection, I would need to provide the correct Repository-name as well, right? Because how does the Database else know which Repository derivation to use? Additionally, I would have to provide the Database name (e.g. "Project") in the query itself, which would not be that big of a deal but I would like to keep this information in the Entity. |
I've been pondering the best way to handle looser mixes of DBs and entities, and have an old issue to deal with it some day: #251 . It can be a bit odd that entities themselves don't have a binding to a DB, but it at least pays off when it comes to generic document types that may be in multiple DBs. Right now, there's the I'll likely investigate options for this when I move to Jakarta Data in the 3.x range of the project, since that will reshuffle some of the assumptions anyway. |
Hello, is it possible to add custom DominoRepository methods apart from the syntax specified by Jakarta EE NoSql? I would like to do some specific querying on the documents without the need to define a view. Thanks.
The text was updated successfully, but these errors were encountered: