'Map an existing database table to a JPA Entity [SOLVED]

I have a Table tmMedia that I'm trying to match to an Entity. But instead of matching the existing table, it creates a new Table tm_media.

Here's my Class Image:

@Entity
@NoArgsConstructor
@AllArgsConstructor
@Data
@Table(name = "tmMedia")
public class Image {
    @Id
    private String fileName;
    //other fields that match the columns of the table

Here's my Controller:

@RestController
@RequestMapping(path = "/api/v1/images")
public class ImageController {

    @Autowired
    private final ImageService imageService;

    public ImageController(ImageService imageService) {
        this.imageService = imageService;
    }

    @GetMapping
    public List<Image> getStudents() {
        return imageService.getImages();
    }
}

Here's my Service:

@Service
public class ImageService {

    @Autowired
    private final ImageRepository imageRepository;

    public ImageService(ImageRepository imageRepository) {
        this.imageRepository = imageRepository;
    }

    @GetMapping
    public List<Image> getImages() {
        return imageRepository.findAll();
    }
}

and the repository:

@Repository
public interface ImageRepository extends JpaRepository<Image, String> {
}

EDIT: Oussama ZAGHDOUD comment solved the problem.

change the name of your table in the dataBase to tm_media



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source