I have a spring boot application connecting to a local mongoDB database. When I try to fetch all records from a collection it returns an empty array.
Facture.class
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
@Document(collection = "Facture")
public class Facture {
@Id
private Long id_facture;
private int num_facture;
private double prix;
private String methode_paiement;
FactureRepository
import com.app.Model.Facture;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface FactureDao extends MongoRepository<Facture, Long> {
}
Postman results
{
"timestamp": "2020-03-25T00:56:13.597+0000",
"status": 404,
"error": "Not Found",
"message": "No message available",
"path": "/api/v1/all"
}
The answer is should change id type to String and thats it works