Spring Rest Respository Collection name case sensitivity












0















I am using Spring Boot and MongoDB, and am trying to expose them over REST using Spring Rest Repositories.



I have a Mongo collection called user and the Java domain model class called User. My Rest Repository looks like this:



@RepositoryRestResource(  collectionResourceRel = "users", path = "users")
public interface UserRepository extends MongoRepository<User, String> {

public User findByEmail(@Param("email") String email);

}


With this in place, I get the advertised benefits of the resource getting automatically exposed over REST. GET, PUT, POST all that jazz.



What I find though is that when I rename the Mongo collection to User, it doesn't find records on the /users endpoint. It is almost as if Spring REST Repositories assumes that the collection name will be in lowercase (yes, I did come across the documentation here - https://docs.spring.io/spring-data/rest/docs/current-SNAPSHOT/reference/html/)




Spring Data REST exposes a collection resource named after the uncapitalized, pluralized version of the domain class the exported repository is handling. Both the name of the resource and the path can be customized using the @RepositoryRestResource on the repository interface.




What I am after is a way to get this configured so that I can use a collection name like User instead of user.



I have searched a fair bit, but haven't been able to come up with answers.



Any help much appreciated!
Cheers!










share|improve this question























  • Have you tried changing collectionResourceRel = "users" to collectionResourceRel = "Users" as the docs suggest?

    – Randy Casburn
    Nov 22 '18 at 4:55






  • 1





    In much the same sentiment as the comment just added, instead of telling us "I followed the guide" show us exactly what you did by providing the necessary code/configuration within the question itself. It kind of sounds like your changed both the collectionResourceRel and the path, when you're only meant to change one of them. Not that I'm going to recommend starting a collection name with an uppercase character anyway, since that goes against common conventions.

    – Neil Lunn
    Nov 22 '18 at 4:58











  • @RandyCasburn Thanks for the quick reply. Yes, tried it but no luck! In fact, when the Mongo collection name is users, it works regardless of whether collectionResourceRel is users or Users :(

    – Forever A Noob
    Nov 22 '18 at 5:03











  • Thanks @NeilLunn, yes, I agree. Unfortunately, I don't have direct control on being able to change the case of the collection :( And no, I didn't change the path, just collectionResourceRel

    – Forever A Noob
    Nov 22 '18 at 5:04













  • You agree to what exactly? We are pretty much asking you to show your code instead of just repeating "did that" or "followed that". Edit your question and show us exactly what you did.

    – Neil Lunn
    Nov 22 '18 at 5:08


















0















I am using Spring Boot and MongoDB, and am trying to expose them over REST using Spring Rest Repositories.



I have a Mongo collection called user and the Java domain model class called User. My Rest Repository looks like this:



@RepositoryRestResource(  collectionResourceRel = "users", path = "users")
public interface UserRepository extends MongoRepository<User, String> {

public User findByEmail(@Param("email") String email);

}


With this in place, I get the advertised benefits of the resource getting automatically exposed over REST. GET, PUT, POST all that jazz.



What I find though is that when I rename the Mongo collection to User, it doesn't find records on the /users endpoint. It is almost as if Spring REST Repositories assumes that the collection name will be in lowercase (yes, I did come across the documentation here - https://docs.spring.io/spring-data/rest/docs/current-SNAPSHOT/reference/html/)




Spring Data REST exposes a collection resource named after the uncapitalized, pluralized version of the domain class the exported repository is handling. Both the name of the resource and the path can be customized using the @RepositoryRestResource on the repository interface.




What I am after is a way to get this configured so that I can use a collection name like User instead of user.



I have searched a fair bit, but haven't been able to come up with answers.



Any help much appreciated!
Cheers!










share|improve this question























  • Have you tried changing collectionResourceRel = "users" to collectionResourceRel = "Users" as the docs suggest?

    – Randy Casburn
    Nov 22 '18 at 4:55






  • 1





    In much the same sentiment as the comment just added, instead of telling us "I followed the guide" show us exactly what you did by providing the necessary code/configuration within the question itself. It kind of sounds like your changed both the collectionResourceRel and the path, when you're only meant to change one of them. Not that I'm going to recommend starting a collection name with an uppercase character anyway, since that goes against common conventions.

    – Neil Lunn
    Nov 22 '18 at 4:58











  • @RandyCasburn Thanks for the quick reply. Yes, tried it but no luck! In fact, when the Mongo collection name is users, it works regardless of whether collectionResourceRel is users or Users :(

    – Forever A Noob
    Nov 22 '18 at 5:03











  • Thanks @NeilLunn, yes, I agree. Unfortunately, I don't have direct control on being able to change the case of the collection :( And no, I didn't change the path, just collectionResourceRel

    – Forever A Noob
    Nov 22 '18 at 5:04













  • You agree to what exactly? We are pretty much asking you to show your code instead of just repeating "did that" or "followed that". Edit your question and show us exactly what you did.

    – Neil Lunn
    Nov 22 '18 at 5:08
















0












0








0








I am using Spring Boot and MongoDB, and am trying to expose them over REST using Spring Rest Repositories.



I have a Mongo collection called user and the Java domain model class called User. My Rest Repository looks like this:



@RepositoryRestResource(  collectionResourceRel = "users", path = "users")
public interface UserRepository extends MongoRepository<User, String> {

public User findByEmail(@Param("email") String email);

}


With this in place, I get the advertised benefits of the resource getting automatically exposed over REST. GET, PUT, POST all that jazz.



What I find though is that when I rename the Mongo collection to User, it doesn't find records on the /users endpoint. It is almost as if Spring REST Repositories assumes that the collection name will be in lowercase (yes, I did come across the documentation here - https://docs.spring.io/spring-data/rest/docs/current-SNAPSHOT/reference/html/)




Spring Data REST exposes a collection resource named after the uncapitalized, pluralized version of the domain class the exported repository is handling. Both the name of the resource and the path can be customized using the @RepositoryRestResource on the repository interface.




What I am after is a way to get this configured so that I can use a collection name like User instead of user.



I have searched a fair bit, but haven't been able to come up with answers.



Any help much appreciated!
Cheers!










share|improve this question














I am using Spring Boot and MongoDB, and am trying to expose them over REST using Spring Rest Repositories.



I have a Mongo collection called user and the Java domain model class called User. My Rest Repository looks like this:



@RepositoryRestResource(  collectionResourceRel = "users", path = "users")
public interface UserRepository extends MongoRepository<User, String> {

public User findByEmail(@Param("email") String email);

}


With this in place, I get the advertised benefits of the resource getting automatically exposed over REST. GET, PUT, POST all that jazz.



What I find though is that when I rename the Mongo collection to User, it doesn't find records on the /users endpoint. It is almost as if Spring REST Repositories assumes that the collection name will be in lowercase (yes, I did come across the documentation here - https://docs.spring.io/spring-data/rest/docs/current-SNAPSHOT/reference/html/)




Spring Data REST exposes a collection resource named after the uncapitalized, pluralized version of the domain class the exported repository is handling. Both the name of the resource and the path can be customized using the @RepositoryRestResource on the repository interface.




What I am after is a way to get this configured so that I can use a collection name like User instead of user.



I have searched a fair bit, but haven't been able to come up with answers.



Any help much appreciated!
Cheers!







mongodb spring-boot spring-data-rest






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 22 '18 at 4:34









Forever A NoobForever A Noob

1817




1817













  • Have you tried changing collectionResourceRel = "users" to collectionResourceRel = "Users" as the docs suggest?

    – Randy Casburn
    Nov 22 '18 at 4:55






  • 1





    In much the same sentiment as the comment just added, instead of telling us "I followed the guide" show us exactly what you did by providing the necessary code/configuration within the question itself. It kind of sounds like your changed both the collectionResourceRel and the path, when you're only meant to change one of them. Not that I'm going to recommend starting a collection name with an uppercase character anyway, since that goes against common conventions.

    – Neil Lunn
    Nov 22 '18 at 4:58











  • @RandyCasburn Thanks for the quick reply. Yes, tried it but no luck! In fact, when the Mongo collection name is users, it works regardless of whether collectionResourceRel is users or Users :(

    – Forever A Noob
    Nov 22 '18 at 5:03











  • Thanks @NeilLunn, yes, I agree. Unfortunately, I don't have direct control on being able to change the case of the collection :( And no, I didn't change the path, just collectionResourceRel

    – Forever A Noob
    Nov 22 '18 at 5:04













  • You agree to what exactly? We are pretty much asking you to show your code instead of just repeating "did that" or "followed that". Edit your question and show us exactly what you did.

    – Neil Lunn
    Nov 22 '18 at 5:08





















  • Have you tried changing collectionResourceRel = "users" to collectionResourceRel = "Users" as the docs suggest?

    – Randy Casburn
    Nov 22 '18 at 4:55






  • 1





    In much the same sentiment as the comment just added, instead of telling us "I followed the guide" show us exactly what you did by providing the necessary code/configuration within the question itself. It kind of sounds like your changed both the collectionResourceRel and the path, when you're only meant to change one of them. Not that I'm going to recommend starting a collection name with an uppercase character anyway, since that goes against common conventions.

    – Neil Lunn
    Nov 22 '18 at 4:58











  • @RandyCasburn Thanks for the quick reply. Yes, tried it but no luck! In fact, when the Mongo collection name is users, it works regardless of whether collectionResourceRel is users or Users :(

    – Forever A Noob
    Nov 22 '18 at 5:03











  • Thanks @NeilLunn, yes, I agree. Unfortunately, I don't have direct control on being able to change the case of the collection :( And no, I didn't change the path, just collectionResourceRel

    – Forever A Noob
    Nov 22 '18 at 5:04













  • You agree to what exactly? We are pretty much asking you to show your code instead of just repeating "did that" or "followed that". Edit your question and show us exactly what you did.

    – Neil Lunn
    Nov 22 '18 at 5:08



















Have you tried changing collectionResourceRel = "users" to collectionResourceRel = "Users" as the docs suggest?

– Randy Casburn
Nov 22 '18 at 4:55





Have you tried changing collectionResourceRel = "users" to collectionResourceRel = "Users" as the docs suggest?

– Randy Casburn
Nov 22 '18 at 4:55




1




1





In much the same sentiment as the comment just added, instead of telling us "I followed the guide" show us exactly what you did by providing the necessary code/configuration within the question itself. It kind of sounds like your changed both the collectionResourceRel and the path, when you're only meant to change one of them. Not that I'm going to recommend starting a collection name with an uppercase character anyway, since that goes against common conventions.

– Neil Lunn
Nov 22 '18 at 4:58





In much the same sentiment as the comment just added, instead of telling us "I followed the guide" show us exactly what you did by providing the necessary code/configuration within the question itself. It kind of sounds like your changed both the collectionResourceRel and the path, when you're only meant to change one of them. Not that I'm going to recommend starting a collection name with an uppercase character anyway, since that goes against common conventions.

– Neil Lunn
Nov 22 '18 at 4:58













@RandyCasburn Thanks for the quick reply. Yes, tried it but no luck! In fact, when the Mongo collection name is users, it works regardless of whether collectionResourceRel is users or Users :(

– Forever A Noob
Nov 22 '18 at 5:03





@RandyCasburn Thanks for the quick reply. Yes, tried it but no luck! In fact, when the Mongo collection name is users, it works regardless of whether collectionResourceRel is users or Users :(

– Forever A Noob
Nov 22 '18 at 5:03













Thanks @NeilLunn, yes, I agree. Unfortunately, I don't have direct control on being able to change the case of the collection :( And no, I didn't change the path, just collectionResourceRel

– Forever A Noob
Nov 22 '18 at 5:04







Thanks @NeilLunn, yes, I agree. Unfortunately, I don't have direct control on being able to change the case of the collection :( And no, I didn't change the path, just collectionResourceRel

– Forever A Noob
Nov 22 '18 at 5:04















You agree to what exactly? We are pretty much asking you to show your code instead of just repeating "did that" or "followed that". Edit your question and show us exactly what you did.

– Neil Lunn
Nov 22 '18 at 5:08







You agree to what exactly? We are pretty much asking you to show your code instead of just repeating "did that" or "followed that". Edit your question and show us exactly what you did.

– Neil Lunn
Nov 22 '18 at 5:08














0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53423947%2fspring-rest-respository-collection-name-case-sensitivity%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53423947%2fspring-rest-respository-collection-name-case-sensitivity%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

mysqli_query(): Empty query in /home/lucindabrummitt/public_html/blog/wp-includes/wp-db.php on line 1924

How to change which sound is reproduced for terminal bell?

Can I use Tabulator js library in my java Spring + Thymeleaf project?