Entity Spring Repository Error with Relationships

2

I'm having a project using Spring Boot to serve JSON in a WebService. An error occurred when I add the Repository class. If you remove it the program starts normally (no errors in the console, I do not speak of features).

The error is: link (I put it in Cjoint because it is too large).

The classes are:

@RepositoryRestResource
public interface Sells extends PagingAndSortingRepository<Long, Sell> {

}

@Entity
public class Sell implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    private Date sellDate;
    @OneToMany(mappedBy = "sell", targetEntity = SellItem.class,
        fetch = FetchType.EAGER, cascade = CascadeType.ALL)
    private List<SellItem> sellItems;
    private Double total;
    // Getters e setter omitidos
}

@Entity
public class SellItem implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    @ManyToOne
    private Product product;
    private Integer quantity;
    @ManyToOne
    @JoinColumn(name = "sell_id")
    private Sell sell;
    //Getters e setter omitidos
}

If needed, ask for more information in the comments.

    
asked by anonymous 08.07.2016 / 20:04

1 answer

0

Hello, I do not know if you have identified your problem yet. I took a look at the error and saw that you have declared your repository in the following way:

public interface Sells extends PagingAndSortingRepository<Long, Sell> {
}

Since the correct way is:

public interface Sells extends PagingAndSortingRepository<Sell, Long> {
}

It seems to me that you just reversed the order of the generic arguments of the PagingAndSortingRepository interface.

    
28.09.2016 / 00:59