MongoDB function not returning anythngMongoDB or CouchDB - fit for production?MongoDB vs. CassandraHow to query MongoDB with “like”?Delete everything in a MongoDB databaseMongoDB relationships: embed or reference?When to Redis? When to MongoDB?How do I drop a MongoDB database from the command line?When to use CouchDB over MongoDB and vice versaSpring Data - MongoDB - JUnit test@PathVariable annotation works different with Proxy based on Interface/Class
Why is my Earth simulation slower than the reality?
Is there any practical application for performing a double Fourier transform? ...or an inverse Fourier transform on a time-domain input?
Sun setting in East!
Are there account age or level requirements for obtaining special research?
Would it be possible to have a GMO that produces chocolate?
I got kicked out from graduate school in the past. How do I include this on my CV?
C++20 constexpr std::copy optimizations for run-time
How would one country purchase another?
Most practical knots for hitching a line to an object while keeping the bitter end as tight as possible, without sag?
What is the history of the university asylum law?
Is using a hyperlink to close a modal a poor design decision?
What's the terminology for this alternative minimization algorithm?
Fancy String Replace
How should I face my manager if I make a mistake because a senior coworker explained something incorrectly to me?
What to say to a student who has failed?
Numbers Decrease while Letters Increase
How to use "Du hast/ Du hattest'?
Would this system work to purify water?
Architectural feasibility of a tiered circular stone keep
Earth rotation discrepancy
How to find multiple values on the same line in any permutation using Notepad++?
Is it safe to remove the bottom chords of a series of garage roof trusses?
What is the hex versus octal timeline?
Shouldn't the "credit score" prevent Americans from going deeper and deeper into personal debt?
MongoDB function not returning anythng
MongoDB or CouchDB - fit for production?MongoDB vs. CassandraHow to query MongoDB with “like”?Delete everything in a MongoDB databaseMongoDB relationships: embed or reference?When to Redis? When to MongoDB?How do I drop a MongoDB database from the command line?When to use CouchDB over MongoDB and vice versaSpring Data - MongoDB - JUnit test@PathVariable annotation works different with Proxy based on Interface/Class
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
Im trying to create a database in spring boot using MongoDB and two errors keep reoccurring.
The first error i get is with the in-built MongoDB function findAll
which gives me the error Failed to instantiate com.accountservice.accountservice.Models.User using constructor NO_CONSTRUCTOR with arguments
which i dont quite understand why i am getting.
The second problem im encountering is when i try to find specific users in my database and use findbyFirstName
which doesn't really give me an error but returns nothing at all.
Here is my code;
User Class;
@Document(collection = "AllUsers")
public class User {
private String bloodGroup;
private String firstName;
@Indexed(direction = IndexDirection.ASCENDING)
private String _surname;
private String _email;
private String _password;
private String _addressline;
private String _postcode;
// Constructor // Getters Setters
Account Service Class;
@Service
public class AccountService
@Autowired
private UserRepository UserRepo;
public User getByfirstName(String firstName)
return UserRepo.findByFirstName(firstName);
public List<User> getAll() // This does not work
return UserRepo.findAll();
User Repository Class;
@Service
@Repository
public interface UserRepository extends MongoRepository<User, String>
public User findByFirstName(String firstName);
Controller Class;
@Component
public class As_Controller
@Autowired
private AccountService Service_functions;
private UserRepository UserRepo;
public As_Controller(UserRepository userRepo)
UserRepo = userRepo;
@ResponseBody
@GetMapping("/getUser/firstName") // This does not return anything
public User getUser( @PathVariable String firstName )
System.out.println("Working"); // This prints in console
return Service_functions.getByfirstName(firstName);
@GetMapping("/getAll")
public List<User> getAllUsers() // This does not work
return Service_functions.getAll();
Any help/suggestions on this matter would be appreciated!
spring mongodb spring-boot
add a comment |
Im trying to create a database in spring boot using MongoDB and two errors keep reoccurring.
The first error i get is with the in-built MongoDB function findAll
which gives me the error Failed to instantiate com.accountservice.accountservice.Models.User using constructor NO_CONSTRUCTOR with arguments
which i dont quite understand why i am getting.
The second problem im encountering is when i try to find specific users in my database and use findbyFirstName
which doesn't really give me an error but returns nothing at all.
Here is my code;
User Class;
@Document(collection = "AllUsers")
public class User {
private String bloodGroup;
private String firstName;
@Indexed(direction = IndexDirection.ASCENDING)
private String _surname;
private String _email;
private String _password;
private String _addressline;
private String _postcode;
// Constructor // Getters Setters
Account Service Class;
@Service
public class AccountService
@Autowired
private UserRepository UserRepo;
public User getByfirstName(String firstName)
return UserRepo.findByFirstName(firstName);
public List<User> getAll() // This does not work
return UserRepo.findAll();
User Repository Class;
@Service
@Repository
public interface UserRepository extends MongoRepository<User, String>
public User findByFirstName(String firstName);
Controller Class;
@Component
public class As_Controller
@Autowired
private AccountService Service_functions;
private UserRepository UserRepo;
public As_Controller(UserRepository userRepo)
UserRepo = userRepo;
@ResponseBody
@GetMapping("/getUser/firstName") // This does not return anything
public User getUser( @PathVariable String firstName )
System.out.println("Working"); // This prints in console
return Service_functions.getByfirstName(firstName);
@GetMapping("/getAll")
public List<User> getAllUsers() // This does not work
return Service_functions.getAll();
Any help/suggestions on this matter would be appreciated!
spring mongodb spring-boot
add a comment |
Im trying to create a database in spring boot using MongoDB and two errors keep reoccurring.
The first error i get is with the in-built MongoDB function findAll
which gives me the error Failed to instantiate com.accountservice.accountservice.Models.User using constructor NO_CONSTRUCTOR with arguments
which i dont quite understand why i am getting.
The second problem im encountering is when i try to find specific users in my database and use findbyFirstName
which doesn't really give me an error but returns nothing at all.
Here is my code;
User Class;
@Document(collection = "AllUsers")
public class User {
private String bloodGroup;
private String firstName;
@Indexed(direction = IndexDirection.ASCENDING)
private String _surname;
private String _email;
private String _password;
private String _addressline;
private String _postcode;
// Constructor // Getters Setters
Account Service Class;
@Service
public class AccountService
@Autowired
private UserRepository UserRepo;
public User getByfirstName(String firstName)
return UserRepo.findByFirstName(firstName);
public List<User> getAll() // This does not work
return UserRepo.findAll();
User Repository Class;
@Service
@Repository
public interface UserRepository extends MongoRepository<User, String>
public User findByFirstName(String firstName);
Controller Class;
@Component
public class As_Controller
@Autowired
private AccountService Service_functions;
private UserRepository UserRepo;
public As_Controller(UserRepository userRepo)
UserRepo = userRepo;
@ResponseBody
@GetMapping("/getUser/firstName") // This does not return anything
public User getUser( @PathVariable String firstName )
System.out.println("Working"); // This prints in console
return Service_functions.getByfirstName(firstName);
@GetMapping("/getAll")
public List<User> getAllUsers() // This does not work
return Service_functions.getAll();
Any help/suggestions on this matter would be appreciated!
spring mongodb spring-boot
Im trying to create a database in spring boot using MongoDB and two errors keep reoccurring.
The first error i get is with the in-built MongoDB function findAll
which gives me the error Failed to instantiate com.accountservice.accountservice.Models.User using constructor NO_CONSTRUCTOR with arguments
which i dont quite understand why i am getting.
The second problem im encountering is when i try to find specific users in my database and use findbyFirstName
which doesn't really give me an error but returns nothing at all.
Here is my code;
User Class;
@Document(collection = "AllUsers")
public class User {
private String bloodGroup;
private String firstName;
@Indexed(direction = IndexDirection.ASCENDING)
private String _surname;
private String _email;
private String _password;
private String _addressline;
private String _postcode;
// Constructor // Getters Setters
Account Service Class;
@Service
public class AccountService
@Autowired
private UserRepository UserRepo;
public User getByfirstName(String firstName)
return UserRepo.findByFirstName(firstName);
public List<User> getAll() // This does not work
return UserRepo.findAll();
User Repository Class;
@Service
@Repository
public interface UserRepository extends MongoRepository<User, String>
public User findByFirstName(String firstName);
Controller Class;
@Component
public class As_Controller
@Autowired
private AccountService Service_functions;
private UserRepository UserRepo;
public As_Controller(UserRepository userRepo)
UserRepo = userRepo;
@ResponseBody
@GetMapping("/getUser/firstName") // This does not return anything
public User getUser( @PathVariable String firstName )
System.out.println("Working"); // This prints in console
return Service_functions.getByfirstName(firstName);
@GetMapping("/getAll")
public List<User> getAllUsers() // This does not work
return Service_functions.getAll();
Any help/suggestions on this matter would be appreciated!
spring mongodb spring-boot
spring mongodb spring-boot
asked Mar 27 at 16:57
stackoverflownstackoverflown
428 bronze badges
428 bronze badges
add a comment |
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55382688%2fmongodb-function-not-returning-anythng%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
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55382688%2fmongodb-function-not-returning-anythng%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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