2 years ago

#75331

test-img

pabab69642

No property by found for type Long

I have a two Entities:

@Data
@Entity
@Table(name = "car")
public class Car {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@NotBlank
@Size(max = 50)
private String name;

@NotNull
@ManyToOne
private Category category;

}

and

@Data
@Entity
@Table(name = "category")
public class Category {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@NotBlank
@Size(max = 50)
private String name;

}

and the CarRepository

@Repository
public interface CarRepository extends PagingAndSortingRepository<Car, Long>          {

List<Car> findAllByCategoryIdByOrderByNameAsc(Long categoryId);

}

But the method "findAllByCategoryIdByOrderByNameAsc" is giving error when I start the spring project..

Error: No property by found for type Long! Traversed path: Car.category.id.

Is this search of "car" by the Id of the category, sorted by the name of the "car" correct?

If I remove the "ByOrderByNameAsc" then it works..

Thanks.

java

jpa

0 Answers

Your Answer

Accepted video resources