Home > Software design >  Dieffrence between _Id and Id in JPA
Dieffrence between _Id and Id in JPA

Time:11-22

What's the difference between those two lines in JPA

public interface PostRepository extends JpaRepository<Post, Long> {
    List<Post> findByUser_Id(Long id);
}

And

public interface PostRepository extends JpaRepository<Post, Long> {
    List<Post> findByUserId(Long id);
}

CodePudding user response:

Its just the name of the method. Other than that, there is no difference between those lines.

CodePudding user response:

The only difference is the method name the class that implements the interface will need to use. They are otherwise identical. If you have a choice, use one that follows your convention, for consistency.

  • Related