Is the a code repository for this class?

Is there a repository for the M220J class. This is the Java class and not the Java Script class. I am having issues implementing the getUserSession() function of the UserDao class and that could help. Here is my code:

public Session getUserSession(String userId) {

    return sessionsCollection.find(Filters.eq("user_id", userId)).first();

What am I doing wrong here?

I looked at the previous posting regarding the repository, but the link I found directs me to the JS class repo, which is completely irrelevant and not usable at all.

M220J is for Java. What do you get? Exception? Error?

Hi @globoblanco,

Lets look at the issues one by one:

If you refer to the code repository, it is provided to you via zip file in handouts: and it is same for every student taking M220J.

I believe you are getting error like incompatible type: required: Document, found: Session. As the hint was already provided in this post, you would need to change the return type of sessionsCollection variable in file.

If you are still unable to resolve, please let me know, I would be happy to share the code.

I completely agree and I am unsure which link you are discussing here. It would help us a lot if you can share it with us, so that we can fix it.
There are multiple courses in the forum, so it might be possible, you got a link which has a solution referred to other course i.e. M220JS. So, it is advised please check the category before you proceed.


This is what you have.

The mongodb-university/mflix-ui link associated with this message is the link I am referring.

Perhaps what needs to happen is to separate the forums on a Per Class basis. This way the People in the Java class don’t have to look at the comments and entries left by those in the Java Script class or Python class.

Can you also please share the code? I have very little time left to complete the assignments for this course.

I appreciate your help so very much.


The link you shared was a lot different, so thanks for sharing this. This is the UI code for mflix application that means source code for building the UI using reactjs. It is not the backend and this is common for all three courses including java course.
Feel free to ignore if this is not useful for you.

There are two changes that needs to be done, there is TODO written in the file to help you identify.

First, on the top around 37 number line of code, where the variable: sessionsCollection is declared. We need to update to as it is expected to return session class type:

 private final MongoCollection<Session> sessionsCollection;

Another, I believe it should be around 54 line number of code:

  sessionsCollection = db.getCollection("sessions", Session.class).withCodecRegistry(pojoCodecRegistry);

I believe this will resolve the error you are having. Let me know if you have any questions.