Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Meaning of Long in JPARepository?

What is Long here and what on basis do we configure this in JpaRepository?

public interface FirstRepository extends JpaRepository<First, Long> {
}
like image 750
newbee Avatar asked Oct 20 '25 14:10

newbee


1 Answers

Long is data type of Primary key (RDBMS) or autogenerated unique document Id(Mongo DB).

public interface FirstRepository extends JpaRepository<EntityName,DataType_of_primaryKey> {

}

Ex: If your Entity is like that:

class Person{
   Long id;
   String name;
}
public interface FirstRepository extends JpaRepository<Person,Long> {
}

Exmplanation

Person -> Entity

id -> Primary key for Person object(Data type should be long)

like image 92
Devendra Kumar Avatar answered Oct 22 '25 04:10

Devendra Kumar