Here is the code for the repository-
public interface QuartzDetailsRepository extends JpaRepository<QuartzDetails, Serializable>{
QuartzDetails findById(int id);
}
Below is the code in the controller.
@Autowired
private QuartzDetailsRepository quartzDetailsRepository;
@Autowired
private QuartzDetails quartzDetails;
public void func(QuartzDetails qz){
quartzDetails = quartzDetailsRepository.save(qz);
System.out.println(quartzDetails.toString());
}
This code works just fine when I execute it for the first-time. However, If I call this function the second time the autowired quartzDetails holds the values of the first-time execution.
As a work-around I did the following
public void func(QuartzDetails qz){
QuartzDetails qdz = quartzDetailsRepository.save(qz);
System.out.println(qdz.toString());
}
My question is - why does the autowired object behave like that? Why are the values of the first time execution persisting in it?