Full Stack Development with Java Spring Boot, React, and MongoDB – Full Course

Hello,
Please can some one help me, I have issue here because I do all same as in course but I have error It is part 1:04:29 I get next error “Couldn’t find PersistentEntity for type class java.lang.String” ?

Hello! Welcome to the community :smile:!

Without seeing the actual code, I’m going to say you’re trying to save a String instead of a class annotated with @Entity and/or @Table. In some part of your code you may have something like this:

@Entity
class AClass {
// Code omitted
}

interface AClassRepository extends CrudRepository<...> {}

@Controller
class AClassController {
  @Autowired
  AClassRepository aClassRepository;

  ResponseEntity saveAClassObject(String possiblyAClassId) {
    aClassRepository.save(possiblyAClassId); // At this point the error should be thrown
    // Maybe you meant to save the found entity?
   // var foundObject = aClassRepository.findById(possiblyAClassId);
   // foundObject.modifyItSomehow();
   // aClassRepository.save(foundObject);

    return ResponseEntity.ok();
  }
}

If you need more help, please share the code related to the issue and the entire error shown on the console (or the log file).

1 Like

1 Like

Could you share your code through git or copy/paste it instead of using images? They’re harder to read :slight_smile:

I don’t have It on git repository… I think that problem is in connection with mangodb but I don’t know how to fix it. In tutorial it is same code as mine but my don’t work.

My problem is that localhost:8080/api/v1/movies only displays empty brackets “[ ]”

My collection name in Movie matches my collection in mongodb

The same problem occurs when I clone the finished project and change the database credentials and collections name to mine.

I tried suggestions from the comments of the youtube video and used delombok to generate getters,setters,and constructions. Still did not work.

Any ideas?

Hello,

Here is my code, I am facing similar issue right now.

package com.samit.movies;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/api/v1/movies")
public class MovieController {
    @Autowired
    private MovieService movieService;

    @GetMapping
    public ResponseEntity <List<Movie>> getAllMovies() {
        return new ResponseEntity<List<Movie>>(movieService.allMovies(), HttpStatus.OK) ;
    }
    
}

I am having the same issue. There is a problem with the connection to Mongodb but I am unable to figure it out.

org.springframework.data.mapping.MappingException: Couldn’t find PersistentEntity for type class java.lang.String

how did you solve it, i am facing the same error.

you should remove the @DocumentReference annotation from the reviewIds field, then you should get the data

1 Like

I removed @DocumentReference but it gives me the 10 empty brackets “{ }” instead the data.
Can you tell me how can i fix that?

This worked for me. Thank You

I’m having the same issue
here is my git repo GitHub - kotkaravishkar/Fullstack-movies-App

Please open a new topic :+1: