I recently started messing with Java and MongoDB and found out that things are not as straight forward as in C#.
In C# i could make a class (as a model) to save it as a Bson Object in MongoDB with the following line.
acc = db.GetCollection<AccountModel>("accounts");
In Java I made my i am getting the class like this:
accs = db.getCollection("accounts", AccountModel.class);
When I am trying to insert this Bson object i populate it like this
public void InsertPlayer(String username){
Model_Account newAccount = new Model_Account();
newAccount.Username = "username";
newAccount.Password = "password";
newAccount.Email = "email@hotmail.com";
accounts.insertOne(newAccount);
}
Very similar to the way I was doing it in C# but in Java I get this error:
Caused by:org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class AccountModel.
From my understanding I need POJO codec to achieve the same functionality is this correct? If yes how can I create it?
Thank you in advance!