Here is my service method:
@Resource
private PersonRepository personRepository;
@Transactional
@Override
public Person create(PersonDTO created) {
LOGGER.debug("Creating a new person with information: " + created);
Person person = Person.getBuilder(created.getFirstName(), created.getLastName()).build();
personRepository.save(person);
foo();
return null;
}
public void foo() {
throw new RuntimeException();
}
As you can see i'm throwing an execption but persistancy takes place non the less.
Here is my datasource config:
<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true" />
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/dbb"/>
<property name="username" value="root" />
<property name="password" value="pass" />
<property name="initialSize" value="10"/>
<property name="maxActive" value="100"/>
<property name="maxIdle" value="15"/>
<property name="minIdle" value="10"/>
<property name="timeBetweenEvictionRunsMillis" value="10000"/>
<property name="minEvictableIdleTimeMillis" value="60000"/>
<property name="validationQuery" value="/* ping */ SELECT 1"/>
<property name="testOnBorrow" value="true"/>
<property name="testWhileIdle" value="true"/>
<property name="removeAbandoned" value="true"/>
<property name="removeAbandonedTimeout" value="300"/>
</bean>
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceUnitName" value="punit"/>
<property name="dataSource" ref="dataSource"/>
<property name="jpaDialect">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaDialect" />
</property>
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="database" value="MYSQL"/>
<!-- <property name="databasePlatform" value="${hibernate.dialect}"/> -->
<property name="showSql" value="false"/>
<property name="generateDdl" value="false"/>
<!-- <property name="hibernate.connection.autocommit" value="false"/> -->
</bean>
</property>
<property name="jpaPropertyMap">
<map>
<entry key="hibernate.connection.autocommit" value="false" />
</map>
</property>
</bean>
Any idea why?
Thanks!