I am trying to save a new entity with Spring Data JPA and Hibernate from JUnit test case. The save method is returning null. If I run from Eclipse as "Run As JUnit" it is working fine and test is passing. But the same test case with maven test is failing with null pointer because JpaRepository's save method is returning null. Any idea?
- Spring data - 1.8.0.RELEASE
- Hibernate - 4.3.8.Final
- Spring - 4.1.5.RELEASE
- Maven - 3.2.5
- Java8, Junit4
Note: I tried both save and saveAndFlush but with no luck.
Service class
Application appl=applicationRepository.saveAndFlush(application);//Returns null Repository class
public interface ApplicationRepository extends JpaRepository<Application, Integer> { @Query(nativeQuery = true, value = "select count (ap1.appn_id) cnt from appn ap1 where ...") List<BigInteger> countByCreatedTSLessThanEqual(String date); }
Transaction?