я есть метод службы addAgent
определяется какSpring Transaction Chaining
@Override
@Transactional(readOnly=false)
public void addAgent(Agent agent, String password,UserProfile userProfile) {
this.userManagerService.addUser(userProfile.getEmail(), password, new String[] {agent.getAgentType()}, userProfile,false);
this.userProvisioningService.enableUser(userProfile.getEmail());
agent.setUserProfileId(userManagerService.getUserProfileId(userProfile.getEmail()));
agent = (Agent)genericDAO.create(agent);
}
addUser
метод пользователь сам по себе является транзакционной. Всякий раз, когда я пытаюсь сохранить данные. Он успешно выполняется для первых двух, но не подходит для создания возраста.
Код работает отлично с junit.
похоже проблема с урегулированием сделки проблема. Означает транзакцию внутри транзакции.
Может ли тело помочь мне, как сделать эту операцию формирования цепочки весной 3.
в журналах его, кажется, как этот
2012-03-19 17:20:28,945 [TP-Processor2] DEBUG jpa.JpaTemplate - Creating new EntityManager for JpaTemplate execution
2012-03-19 17:20:28,949 [TP-Processor2] DEBUG impl.SessionImpl - opened session at timestamp: 13321578289
2012-03-19 17:20:29,161 [TP-Processor2] DEBUG def.AbstractSaveEventListener - delaying identity-insert due to no transaction in progress
2012-03-19 17:20:29,163 [TP-Processor2] DEBUG jpa.JpaTemplate - Closing new EntityManager after JPA template execution
2012-03-19 17:20:29,164 [TP-Processor2] DEBUG jpa.EntityManagerFactoryUtils - Closing JPA EntityManager
может быть
delaying identity-insert due to no transaction in progress
ApplicationContext. xml
<bean id="txManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<tx:annotation-driven transaction-manager="txManager" />
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="persistenceUnitName" value="B2C_BROKER" />
<property name="jpaVendorAdapter">
<bean id="jpaAdapter"
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="database" value="MYSQL" />
<property name="showSql" value="false" />
<property name="generateDdl" value="false" />
</bean>
</property>
</bean>
<bean id="genericDAO" class="com.core.orm.dao.GenericDAOImpl">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
найти другой журнал:
2012-03-19 20:13:21,074 [TP-Processor3] DEBUG jpa.JpaTemplate - Creating new EntityManager for JpaTemplate execution
2012-03-19 20:13:21,082 [TP-Processor3] DEBUG impl.SessionImpl - opened session at timestamp: 13321682010
2012-03-19 20:13:21,082 [TP-Processor3] DEBUG impl.SessionImpl - opened session at timestamp: 13321682010
2012-03-19 20:13:21,090 [TP-Processor3] TRACE impl.SessionImpl - setting flush mode to: AUTO
2012-03-19 20:13:21,090 [TP-Processor3] TRACE impl.SessionImpl - setting flush mode to: AUTO
2012-03-19 20:13:21,096 [TP-Processor3] TRACE impl.SessionImpl - setting cache mode to: NORMAL
2012-03-19 20:13:21,096 [TP-Processor3] TRACE impl.SessionImpl - setting cache mode to: NORMAL
2012-03-19 20:13:21,100 [TP-Processor3] TRACE def.AbstractSaveEventListener - transient instance of: com.xchange.agent.domain.Agent
2012-03-19 20:13:21,100 [TP-Processor3] TRACE def.AbstractSaveEventListener - transient instance of: com.xchange.agent.domain.Agent
2012-03-19 20:13:21,103 [TP-Processor3] TRACE def.DefaultPersistEventListener - saving transient instance
2012-03-19 20:13:21,103 [TP-Processor3] TRACE def.DefaultPersistEventListener - saving transient instance
2012-03-19 20:13:21,106 [TP-Processor3] TRACE def.AbstractSaveEventListener - saving [com.xchange.agent.domain.Agent#<null>]
2012-03-19 20:13:21,106 [TP-Processor3] TRACE def.AbstractSaveEventListener - saving [com.xchange.agent.domain.Agent#<null>]
2012-03-19 20:13:21,110 [TP-Processor3] DEBUG def.AbstractSaveEventListener - delaying identity-insert due to no transaction in progress
2012-03-19 20:13:21,110 [TP-Processor3] DEBUG def.AbstractSaveEventListener - delaying identity-insert due to no transaction in progress
2012-03-19 20:13:21,114 [TP-Processor3] DEBUG jpa.JpaTemplate - Closing new EntityManager after JPA template execution
2012-03-19 20:13:21,115 [TP-Processor3] DEBUG jpa.EntityManagerFactoryUtils - Closing JPA EntityManager
2012-03-19 20:13:21,117 [TP-Processor3] TRACE impl.SessionImpl - closing session
2012-03-19 20:13:21,117 [TP-Processor3] TRACE impl.SessionImpl - closing session
2012-03-19 20:13:21,119 [TP-Processor3] TRACE jdbc.ConnectionManager - connection already null in cleanup : no action
2012-03-19 20:13:21,119 [TP-Processor3] TRACE jdbc.ConnectionManager - connection already null in cleanup : no action
как это не удается? Какая ошибка? –
проблема: на сервере нет журналов ошибок (весна debug включена), но последняя строка (агент = (агент) genericDAO.create (agent);) выполняется успешно, но идентификатор агента, который является автогенерированным, по-прежнему равен нулю. –
см. Это: http://www.ibm.com/developerworks/java/library/j-ts1/index.html#listing4 – subodh