Tigor Mangatur Manurung Tigor Mangatur Manurung - 7 months ago 158
Java Question

Spring JPA : Insert succesfully but Update Failed (javax.persistence.PersistenceException: error during managed flush)

I have problem with my code,

application.properties

server.port=8080
spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:mysql://localhost:3306/example
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.username=root
spring.datasource.password=
spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect
spring.jpa.hibernate.ddl-auto=update
security.enable-csrf=False
spring.data.elasticsearch.repositories.enabled=false
spring.activemq.pool.enabled=false
spring.activemq.pool.configuration.create-connection-on-startup=false
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=true
logging.level.org.springframework.web=DEBUG
logging.level.org.hibernate=DEBUG
logging.file=tigor.log


Bean (MsParameter.java)

package com.example.db.domain;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

@Entity
@Table(name = "ms_parameter", uniqueConstraints = @UniqueConstraint(columnNames = "parameter_name"))
public class MsParameter /*extends _CoreBeans*/{
@Id
@Column(name="parameter_id")
@GeneratedValue(strategy=GenerationType.IDENTITY)
private int parameter_id;
private String parameter_name;
private String parameter_value;


public int getParameter_id() {
return parameter_id;
}
public void setParameter_id(int parameter_id) {
this.parameter_id = parameter_id;
}
@Column(name = "parameter_name", unique = true, nullable = false, length = 30)
public String getParameter_name() {
return parameter_name;
}
public void setParameter_name(String parameter_name) {
this.parameter_name = parameter_name;
}

@Column(name = "parameter_value", nullable = false, length = 100)
public String getParameter_value() {
return parameter_value;
}
public void setParameter_value(String parameter_value) {
this.parameter_value = parameter_value;
}

}


Repository (MsParameterRepo.java)

package com.example.db.repository;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;

import com.example.db.domain.MsParameter;

public interface MsParameterRepo extends CrudRepository<MsParameter, Integer>{
@Query("SELECT p FROM MsParameter p WHERE p.parameter_id = :id ")
MsParameter findById(@Param("id")int id);
}


Service Interface (MsParameterService.java)

package com.example.db.service;

import java.util.Collection;

import com.btpns.hobit.db.domain.MsParameter;

public interface MsParameterServiceInterface {
public MsParameter save(MsParameter p);
public Boolean delete(Integer Id);
public MsParameter edit(MsParameter param);
public MsParameter find(Integer Id);
public Collection<MsParameter> getAll();
}


Service Interface Implementation (MsParameterServiceImpl.java)

package com.example.db.service;

import java.util.Collection;

import javax.transaction.Transactional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Transactional;

import com.example.db.domain.MsParameter;
import com.example.db.repository.MsParameterRepo;

@Service
@Transactional
public class MsParameterServiceImpl implements MsParameterServiceInterface{

@Autowired
protected MsParameterRepo repo;

@Override
public MsParameter save(MsParameter p) {
// TODO Auto-generated method stub
return repo.save(p);
}

@Override
public Boolean delete(Integer Id) {
MsParameter p = repo.findOne(Id);

if (p!=null){
repo.delete(p);
return true;
}

return false;
}

@Override
public MsParameter edit(MsParameter param) {
// TODO Auto-generated method stub
return this.save(param);
}

@Override
public MsParameter find(Integer Id) {
// TODO Auto-generated method stub
return repo.findOne(Id);
}

@Override
public Collection<MsParameter> getAll() {
Iterable<MsParameter> itr = repo.findAll();
return (Collection<MsParameter>)itr;
}

}


Controller (SettingParameterController.java)

package com.example.module.settings;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.example.app.core.CoreController;
import com.example.db.domain.MsParameter;
import com.example.db.domain.ResponseBean;
import com.example.db.repository.MsParameterRepo;
import com.example.db.service.MsParameterServiceInterface;

@RestController
@RequestMapping("/settingparameter")
@Transactional
public class SettingParameterController extends CoreController {
@Autowired
MsParameterRepo msParam;

@Autowired
MsParameterServiceInterface msParameterServiceInterface;
//
@RequestMapping(value="/save",method=RequestMethod.POST)
public ResponseBean save(@RequestBody MsParameter param){
try {
msParameterServiceInterface.save(param); //doesn't work
return new ResponseBean("", true);
} catch (Exception e) {
return new ResponseBean("", false);
}
}

}


with code above, insert is success, but when update error (in the log, update query is executed but when flush is error). here is log error :

2016-04-27 10:22:34.866 DEBUG 7776 --- [io-8081-exec-11] org.hibernate.loader.Loader : Result set row: 0
2016-04-27 10:22:34.867 DEBUG 7776 --- [io-8081-exec-11] org.hibernate.loader.Loader : Result row: EntityKey[com.example.db.domain.MsParameter#34]
2016-04-27 10:22:34.867 DEBUG 7776 --- [io-8081-exec-11] o.h.engine.internal.TwoPhaseLoad : Resolving associations for [com.example.db.domain.MsParameter#34]
2016-04-27 10:22:34.867 DEBUG 7776 --- [io-8081-exec-11] o.h.engine.internal.TwoPhaseLoad : Done materializing entity [com.example.db.domain.MsParameter#34]
2016-04-27 10:22:34.867 DEBUG 7776 --- [io-8081-exec-11] o.h.r.j.i.LogicalConnectionManagedImpl : Initiating JDBC connection release from afterStatement
2016-04-27 10:22:34.868 DEBUG 7776 --- [io-8081-exec-11] org.hibernate.loader.Loader : Done entity load
2016-04-27 10:22:34.869 DEBUG 7776 --- [io-8081-exec-11] o.h.e.i.AbstractFlushingEventListener : Processing flush-time cascades
2016-04-27 10:22:34.869 DEBUG 7776 --- [io-8081-exec-11] o.h.e.i.AbstractFlushingEventListener : Dirty checking collections
2016-04-27 10:22:34.869 DEBUG 7776 --- [io-8081-exec-11] o.h.e.i.AbstractFlushingEventListener : Flushed: 0 insertions, 1 updates, 0 deletions to 1 objects
2016-04-27 10:22:34.869 DEBUG 7776 --- [io-8081-exec-11] o.h.e.i.AbstractFlushingEventListener : Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
2016-04-27 10:22:34.870 DEBUG 7776 --- [io-8081-exec-11] o.hibernate.internal.util.EntityPrinter : Listing entities:
2016-04-27 10:22:34.870 DEBUG 7776 --- [io-8081-exec-11] o.hibernate.internal.util.EntityPrinter : com.example.db.domain.MsParameter{parameter_value=thisisvalue, parameter_name=thisisname, parameter_id=34}
2016-04-27 10:22:34.871 DEBUG 7776 --- [io-8081-exec-11] org.hibernate.SQL :
update
ms_parameter
set
parameter_name=?,
parameter_value=?
where
parameter_id=?
Hibernate:
update
ms_parameter
set
parameter_name=?,
parameter_value=?
where
parameter_id=?
2016-04-27 10:22:34.872 DEBUG 7776 --- [io-8081-exec-11] o.h.r.j.i.LogicalConnectionManagedImpl : Initiating JDBC connection release from afterStatement
2016-04-27 10:22:34.876 WARN 7776 --- [io-8081-exec-11] com.arjuna.ats.arjuna : ARJUNA012125: TwoPhaseCoordinator.beforeCompletion - failed for SynchronizationImple< 0:ffffc0a8000f:ca1e:57202b23:2f, org.hibernate.resource.transaction.backend.jta.internal.synchronization.RegisteredSynchronization@10f13e52 >

javax.persistence.PersistenceException: error during managed flush
at org.hibernate.jpa.internal.EntityManagerImpl$CallbackExceptionMapperImpl.mapManagedFlushFailure(EntityManagerImpl.java:240) ~[hibernate-entitymanager-5.1.0.Final.jar:5.1.0.Final]
at org.hibernate.internal.SessionImpl.flushBeforeTransactionCompletion(SessionImpl.java:3142) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
at org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:2352) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.beforeTransactionCompletion(JdbcCoordinatorImpl.java:485) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
at org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorImpl.beforeCompletion(JtaTransactionCoordinatorImpl.java:316) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
at org.hibernate.resource.transaction.backend.jta.internal.synchronization.SynchronizationCallbackCoordinatorNonTrackingImpl.beforeCompletion(SynchronizationCallbackCoordinatorNonTrackingImpl.java:47) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
at org.hibernate.resource.transaction.backend.jta.internal.synchronization.RegisteredSynchronization.beforeCompletion(RegisteredSynchronization.java:37) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:76) ~[jta-5.3.2.Final.jar:5.3.2.Final]
at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:368) ~[arjuna-5.3.2.Final.jar:5.3.2.Final]
at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:91) ~[arjuna-5.3.2.Final.jar:5.3.2.Final]
at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:162) ~[arjuna-5.3.2.Final.jar:5.3.2.Final]
at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1200) ~[jta-5.3.2.Final.jar:5.3.2.Final]
at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:126) [jta-5.3.2.Final.jar:5.3.2.Final]
at org.springframework.transaction.jta.JtaTransactionManager.doCommit(JtaTransactionManager.java:1021) [spring-tx-4.3.0.RC1.jar:4.3.0.RC1]
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:761) [spring-tx-4.3.0.RC1.jar:4.3.0.RC1]
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:730) [spring-tx-4.3.0.RC1.jar:4.3.0.RC1]
at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:485) [spring-tx-4.3.0.RC1.jar:4.3.0.RC1]
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:291) [spring-tx-4.3.0.RC1.jar:4.3.0.RC1]
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) [spring-tx-4.3.0.RC1.jar:4.3.0.RC1]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) [spring-aop-4.3.0.RC1.jar:4.3.0.RC1]
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:655) [spring-aop-4.3.0.RC1.jar:4.3.0.RC1]
at com.example.db.service.MsParameterServiceImpl$$EnhancerBySpringCGLIB$$f4d2a421.save(<generated>) [classes/:0.0.1-SNAPSHOT]
at com.example.module.settings.SettingParameterController.save(SettingParameterController.java:38) [classes/:0.0.1-SNAPSHOT]
at com.example.module.settings.SettingParameterController$$FastClassBySpringCGLIB$$4161873e.invoke(<generated>) [classes/:0.0.1-SNAPSHOT]
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) [spring-core-4.3.0.RC1.jar:4.3.0.RC1]
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:651) [spring-aop-4.3.0.RC1.jar:4.3.0.RC1]
at com.example.module.settings.SettingParameterController$$EnhancerBySpringCGLIB$$e6030a84.save(<generated>) [classes/:0.0.1-SNAPSHOT]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_66]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_66]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_66]
at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_66]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221) [spring-web-4.3.0.RC1.jar:4.3.0.RC1]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136) [spring-web-4.3.0.RC1.jar:4.3.0.RC1]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:114) [spring-webmvc-4.3.0.RC1.jar:4.3.0.RC1]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827) [spring-webmvc-4.3.0.RC1.jar:4.3.0.RC1]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738) [spring-webmvc-4.3.0.RC1.jar:4.3.0.RC1]
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) [spring-webmvc-4.3.0.RC1.jar:4.3.0.RC1]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963) [spring-webmvc-4.3.0.RC1.jar:4.3.0.RC1]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897) [spring-webmvc-4.3.0.RC1.jar:4.3.0.RC1]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) [spring-webmvc-4.3.0.RC1.jar:4.3.0.RC1]
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872) [spring-webmvc-4.3.0.RC1.jar:4.3.0.RC1]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:648) [servlet-api.jar:na]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) [spring-webmvc-4.3.0.RC1.jar:4.3.0.RC1]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) [servlet-api.jar:na]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292) [catalina.jar:8.0.33]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) [catalina.jar:8.0.33]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) [tomcat-websocket.jar:8.0.33]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) [catalina.jar:8.0.33]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) [catalina.jar:8.0.33]
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) [spring-web-4.3.0.RC1.jar:4.3.0.RC1]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.3.0.RC1.jar:4.3.0.RC1]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) [catalina.jar:8.0.33]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) [catalina.jar:8.0.33]
at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:87) [spring-web-4.3.0.RC1.jar:4.3.0.RC1]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.3.0.RC1.jar:4.3.0.RC1]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) [catalina.jar:8.0.33]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) [catalina.jar:8.0.33]
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77) [spring-web-4.3.0.RC1.jar:4.3.0.RC1]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.3.0.RC1.jar:4.3.0.RC1]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) [catalina.jar:8.0.33]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) [catalina.jar:8.0.33]
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121) [spring-web-4.3.0.RC1.jar:4.3.0.RC1]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.3.0.RC1.jar:4.3.0.RC1]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) [catalina.jar:8.0.33]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) [catalina.jar:8.0.33]
at org.springframework.boot.context.web.ErrorPageFilter.doFilter(ErrorPageFilter.java:120) [spring-boot-1.4.0.M2.jar:1.4.0.M2]
at org.springframework.boot.context.web.ErrorPageFilter.access$000(ErrorPageFilter.java:61) [spring-boot-1.4.0.M2.jar:1.4.0.M2]
at org.springframework.boot.context.web.ErrorPageFilter$1.doFilterInternal(ErrorPageFilter.java:95) [spring-boot-1.4.0.M2.jar:1.4.0.M2]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.3.0.RC1.jar:4.3.0.RC1]
at org.springframework.boot.context.web.ErrorPageFilter.doFilter(ErrorPageFilter.java:113) [spring-boot-1.4.0.M2.jar:1.4.0.M2]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) [catalina.jar:8.0.33]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) [catalina.jar:8.0.33]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212) [catalina.jar:8.0.33]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) [catalina.jar:8.0.33]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) [catalina.jar:8.0.33]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141) [catalina.jar:8.0.33]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) [catalina.jar:8.0.33]
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616) [catalina.jar:8.0.33]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) [catalina.jar:8.0.33]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522) [catalina.jar:8.0.33]
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095) [tomcat-coyote.jar:8.0.33]
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672) [tomcat-coyote.jar:8.0.33]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1502) [tomcat-coyote.jar:8.0.33]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1458) [tomcat-coyote.jar:8.0.33]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_66]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_66]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-util.jar:8.0.33]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_66]
Caused by: java.lang.NullPointerException: null
at com.arjuna.ats.internal.jdbc.ConnectionManager.create(ConnectionManager.java:91) ~[jdbc-5.3.2.Final.jar:5.3.2.Final]
at org.springframework.boot.jta.narayana.NarayanaDataSourceBean.getConnection(NarayanaDataSourceBean.java:59) ~[spring-boot-1.4.0.M2.jar:1.4.0.M2]
at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
at org.hibernate.internal.AbstractSessionImpl$NonContextualJdbcConnectionAccess.obtainConnection(AbstractSessionImpl.java:386) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.acquireConnectionIfNeeded(LogicalConnectionManagedImpl.java:84) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.getPhysicalConnection(LogicalConnectionManagedImpl.java:109) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.connection(StatementPreparerImpl.java:47) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$1.doPrepare(StatementPreparerImpl.java:87) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:172) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareStatement(StatementPreparerImpl.java:78) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
at org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl.buildBatchStatement(AbstractBatchImpl.java:136) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
at org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl.getBatchStatement(AbstractBatchImpl.java:125) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:3049) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2985) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:3365) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
at org.hibernate.action.internal.EntityUpdateAction.execute(EntityUpdateAction.java:145) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:560) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:434) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:337) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1295) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:468) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
at org.hibernate.internal.SessionImpl.flushBeforeTransactionCompletion(SessionImpl.java:3135) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]
... 86 common frames omitted

2016-04-27 10:22:34.877 DEBUG 7776 --- [io-8081-exec-11] o.h.r.j.i.LogicalConnectionManagedImpl : Initiating JDBC connection release from afterTransaction
2016-04-27 10:22:34.880 DEBUG 7776 --- [io-8081-exec-11] m.m.a.RequestResponseBodyMethodProcessor : Written [com.example.db.domain.ResponseBean@2044edf3] as "application/json" using [org.springframework.http.converter.json.MappingJackson2HttpMessageConverter@142a179a]
2016-04-27 10:22:34.880 DEBUG 7776 --- [io-8081-exec-11] o.s.web.servlet.DispatcherServlet : Null ModelAndView returned to DispatcherServlet with name 'dispatcherServlet': assuming HandlerAdapter completed request handling
2016-04-27 10:22:34.880 DEBUG 7776 --- [io-8081-exec-11] o.h.e.jdbc.internal.JdbcCoordinatorImpl : HHH000420: Closing un-released batch
2016-04-27 10:22:34.880 DEBUG 7776 --- [io-8081-exec-11] o.s.web.servlet.DispatcherServlet : Successfully completed request


Is there any misconfiguration or how to use spring jpa correctly? thank! :)

Answer

Arghhh, my bad! After removing dependency "narayana" method save is worked!

how to remove narayana dependency? open pom.xml (if use maven) and delete this following line :

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-jta-narayana</artifactId>
</dependency>

Thank You! :)