title: Spring data JPA repository delete query getting fired after returning from service
body: <p>I am using spring data jpa in my spring boot application.</p>
  
  <p>Below is my SchoolService method to delete school by school id.</p>
  
  <pre><code>    @Override
      @Transactional(propagation = Propagation.REQUIRED, readOnly = false)
      public boolean deleteSchool(Long id) {
          log.debug("Deleting school entry with the school id: {}", id);
          try {
              schoolRepository.delete(id);
              return true;
          } catch(Exception e){
              log.error(e.toString());
              return false;
          }
      }
  </code></pre>
  
  <p>and my SchoolRepository is as follows.</p>
  
  <pre><code>public interface SchoolRepository&lt;School, Long&gt; extends PagingAndSortingRepository&lt;School, Long&gt; {
  
  
  }
  </code></pre>
  
  <p>When there is some exception while deleting a school, this service method should throw an exception which should be caught and false should be returned indicating that the delete operation has failed.</p>
  
  <p>But here in above case, it returns true and then it throws an exception. Not sure why?</p>
  
  <p>Below is the stacktrace</p>
  
  <pre><code>2016-07-27 16:13:30.809 DEBUG 7650 --- [nio-8080-exec-6] c.sts.app.core.common.aop.LoggingAspect  : Enter: com.sts.app.school.service.SchoolService.deleteSchool() with argument[s] = [1]
  2016-07-27 16:13:30.809 DEBUG 7650 --- [nio-8080-exec-6] c.s.a.s.service.impl.SchoolServiceImpl   : Deleting school entry with the school id: 1
  Hibernate: 
      select
          school0_.id as id1_4_0_,
          school0_.created_by as created_2_4_0_,
          school0_.created_date as created_3_4_0_,
          school0_.last_modified_by as last_mod4_4_0_,
          school0_.last_modified_date as last_mod5_4_0_,
          school0_.address as address6_4_0_,
          school0_.name as name7_4_0_ 
      from
          schools school0_ 
      where
          school0_.id=?
  2016-07-27 16:13:30.812 DEBUG 7650 --- [nio-8080-exec-6] c.sts.app.core.common.aop.LoggingAspect  : Exit: com.sts.app.school.service.SchoolService.deleteSchool() with result = true
  Hibernate: 
      delete 
      from
          schools 
      where
          id=?
  2016-07-27 16:13:30.815  WARN 7650 --- [nio-8080-exec-6] o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Error: 1451, SQLState: 23000
  2016-07-27 16:13:30.815 ERROR 7650 --- [nio-8080-exec-6] o.h.engine.jdbc.spi.SqlExceptionHelper   : Cannot delete or update a parent row: a foreign key constraint fails (`blank_app`.`students`, CONSTRAINT `FK_d8qlrs5j411ofxq8uy2nlhxm` FOREIGN KEY (`school_id`) REFERENCES `schools` (`id`))
  2016-07-27 16:13:30.816  WARN 7650 --- [nio-8080-exec-6] o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Warning Code: 1451, SQLState: 23000
  2016-07-27 16:13:30.816  WARN 7650 --- [nio-8080-exec-6] o.h.engine.jdbc.spi.SqlExceptionHelper   : Cannot delete or update a parent row: a foreign key constraint fails (`blank_app`.`students`, CONSTRAINT `FK_d8qlrs5j411ofxq8uy2nlhxm` FOREIGN KEY (`school_id`) REFERENCES `schools` (`id`))
  org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement
      at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:259)
      at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:225)
      at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:521)
      at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:761)
      at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:730)
      at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:485)
      at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:291)
      at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
      at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
      at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208)
      at com.sun.proxy.$Proxy126.deleteSchool(Unknown Source)
      at com.sts.app.school.web.SchoolController.deleteSchool(SchoolController.java:71)
      at com.sts.app.school.web.SchoolController$$FastClassByCGLIB$$a5f9e3ee.invoke(&lt;generated&gt;)
  </code></pre>