-
Notifications
You must be signed in to change notification settings - Fork 192
Expose some private methods of the template and repository #1310
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
Comments
Isn't 'protected' sufficient for accessing with a subclass? Can you give an example of what you are wanting to do? |
Hi @mikereiche With protected would be perfect but they are with default visibility (only accessible within the package). |
"there are classes with the constructor not visible and others with the public constructor. " I believe the constructors are/should be only called by corresponding method in Reactive/CouchbaseTemplate and none of them need to be public. Can you explain the case where they would need to be public? Can you explain the case where you would need getScope() and getCollection() to be public?
|
Hi I would need that For example, I extends public class CouchbaseBaseRepository<T> extends SimpleCouchbaseRepository<T, String> {
@Override
@SuppressWarnings("unchecked")
public <S extends T> S save(S entity) {
Assert.notNull(entity, "Entity must not be null!");
// if entity has non-null, non-zero version property, then replace()
S result;
if (hasNonZeroVersionProperty(entity, operations.getConverter())) {
result = (S) operations.replaceById(getJavaType()).inScope(getScope()).inCollection(getCollection()).one(entity);
} else {
result = (S) operations.upsertById(getJavaType()).inScope(getScope()).inCollection(getCollection()).one(entity);
} else {
//Creating new document
result = (S) operations.insertById(getJavaType()).inScope(getScope()).inCollection(getCollection()).one(entity);
}
return result;
} On the other hand, I also extend the template by adding another operation and it would be very useful to use the method
Thank you very much |
Ok - that code isn't even going to compile with the two consecutive else's without if's .
But why? |
Ok, I will make a PR with that change.
Both the repository and the template are public and, therefore, extensible. I have added my own operations to the repository (and, consequently, to the template). The operations that I have added are, for example, the saving with the possibility of the insertById, operations to work the api of subdocuments, I have added the touch operation... All these operations now I have to make them compatible with the scopes and the collections and, since the repositories and the templates are public, I ask that the methods getScope, getCollection and potentiallyConvertRuntimeException are protected. I hope I have explained myself better. If you have any doubt, we will be happy to talk about it. Best regards |
getAndTouch is already present - see #982
insertById will be fixed with see #1277.
Is this to convert CasMismatch to OptimisticLockingFailure as for #1314? The issue seems to be the documentation, not the code as the code always converted it to DataIntegrityViolation. We're not going to open up APIs to work-around bugs as an alternative to fixing bugs. Can you create a PR for the addition of Subdocument support? Thanks. |
Hello
Both repositories and templates are extensible but I have found several private methods that I would need to be able to extend efficiently.
spring-data-couchbase/src/main/java/org/springframework/data/couchbase/repository/support/CouchbaseRepositoryBase.java
Line 71 in 6e3c626
spring-data-couchbase/src/main/java/org/springframework/data/couchbase/repository/support/CouchbaseRepositoryBase.java
Line 86 in 6e3c626
spring-data-couchbase/src/main/java/org/springframework/data/couchbase/core/ReactiveCouchbaseTemplate.java
Line 168 in 6e3c626
ExecutableXXXOperationSupport
andReactiveXXXOperationSupport
there are classes with the constructor not visible and others with the public constructor. I think that the ideal would be that all of them have the public constructor to be able to extend and to be able to customize some operation.Sample:
spring-data-couchbase/src/main/java/org/springframework/data/couchbase/core/ReactiveExistsByIdOperationSupport.java
Line 40 in 6e3c626
spring-data-couchbase/src/main/java/org/springframework/data/couchbase/core/ReactiveInsertByIdOperationSupport.java
Line 41 in 6e3c626
Something similar was done on this issue:
What do you think?
Thanks in advance
The text was updated successfully, but these errors were encountered: