Guten Tag ,
Was macht man in Spring um NullPointer zu vermeiden , falls Repository null liefert?
Ich habe folgendes Repository:
Aber wenn ich noch keine Daten in der DB habe ,liefert es natürlich null.
Folgende code liefert mir deswegen Nullpointerexception:
[/code]
There was an unexpected error (type=Internal Server Error, status=500).
Null return value from advice does not match primitive return type for: public abstract int scoSpring.repo.ProgrammRepository.getMaxId()
org.springframework.aop.AopInvocationException: Null return value from advice does not match primitive return type for: public abstract int scoSpring.repo.ProgrammRepository.getMaxId()
Was macht man in Spring um NullPointer zu vermeiden , falls Repository null liefert?
Ich habe folgendes Repository:
Java:
@Repository
public interface ProgrammRepository extends JpaRepository<Programm,ProgrammPK>{
@Query(value="select max(programm_id) from sco.programm" ,nativeQuery=true)
int getMaxId();
}
Folgende code liefert mir deswegen Nullpointerexception:
Java:
int programm_id_int = progRepository.getMaxId()+1;
There was an unexpected error (type=Internal Server Error, status=500).
Null return value from advice does not match primitive return type for: public abstract int scoSpring.repo.ProgrammRepository.getMaxId()
org.springframework.aop.AopInvocationException: Null return value from advice does not match primitive return type for: public abstract int scoSpring.repo.ProgrammRepository.getMaxId()