Очень короткий мой метод session.save dao не фиксирует (UPDATE: и не имеет соответствующего метода службы), если я вручную не укажу session.flush().Сценарий Спящего Спора Не совершать без промаха
Эта проблема была обсуждена ранее в stackoverflow. here. Но пока нет удовлетворительного ответа, и я считаю, что программный снимок программно - это плохая практика. Помощь с диагнозами будет полезна.
Моя_служба Layer:
@Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW)
public void saveTestType(TestType tt) throws TestStructureException
{
SS.getLogger().debug("Saving tt: Id before saving is"+tt.getId());
testTypeDao.saveNewTestType(tt);
SS.getLogger().debug("Saving tt: Id after saving is"+tt.getId());
}
Мой Dao Слой
@Transactional(propagation = Propagation.MANDATORY)
public void saveNewTestType(TestType tt) throws TestStructureException
{
Session session = this.sessionFactory.openSession();
try
{
SS.getLogger().debug("Saving TT: "+tt);
session.saveOrUpdate(tt);
session.flush();
}
catch(Exception e)
{
SS.getLogger().error(e.getMessage(),e);
throw new TestStructureException(e.getMessage(),e.getStackTrace());
}
}
Мой appContext.xml (я надеюсь, у меня есть немного излишним в здесь)
<beans xmlns="http://www.springframework.org/schema/beans"
\t xmlns:context="http://www.springframework.org/schema/context"
\t xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
\t xmlns:tx="http://www.springframework.org/schema/tx"
\t xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd">
<!-- View Resolver -->
\t
\t <bean id="jspViewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
\t
\t <!-- i18n -->
\t <bean id="messageSource"
\t \t class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
\t \t <property name="basename" value="classpath:messages" />
\t \t <property name="defaultEncoding" value="UTF-8" />
\t </bean>
\t <bean id="localeChangeInterceptor"
\t \t class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
\t \t <property name="paramName" value="lang" />
\t </bean>
\t <bean id="localeResolver"
\t \t class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
\t \t <property name="defaultLocale" value="en" />
\t </bean>
\t <bean id="handlerMapping"
\t \t class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
\t \t <property name="interceptors">
\t \t \t <ref bean="localeChangeInterceptor" />
\t \t </property>
\t </bean>
\t <!-- Hibernate -->
\t <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
\t \t destroy-method="close">
\t \t <property name="driverClass" value="org.postgresql.Driver" />
\t \t <property name="jdbcUrl" value="jdbc:postgresql://localhost/test" />
\t \t <property name="user" value="testuser" />
\t \t <property name="password" value="buddybuddy" />
\t \t <!-- C3P0 properties refer: http://www.mchange.com/projects/c3p0/ -->
\t \t <property name="acquireIncrement" value="2" />
\t \t <property name="minPoolSize" value="3" />
\t \t <property name="maxPoolSize" value="50" />
\t \t <property name="maxIdleTime" value="600" />
\t </bean>
\t <!-- Hibernate session factory -->
\t <bean id="sfhbmSessionFactory"
\t \t class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
\t \t <property name="dataSource">
\t \t \t <ref bean="dataSource" />
\t \t </property>
\t \t <property name="annotatedClasses">
\t \t \t <list>
\t \t \t \t <value>com.prototype2.model.user.UserAdmin</value>
\t \t \t \t <value>com.prototype2.model.assessment.MultipleChoiceItem</value>
\t \t \t \t ...
\t \t \t \t <value>com.prototype2.model.scores.UserRawScore</value>
\t \t \t \t <value>com.prototype2.model.scores.UserTrueScore</value>
\t \t \t </list>
\t \t </property>
\t \t <property name="mappingResources">
\t \t \t <list>
\t \t \t \t <value>hibernatemap.cfg.xml</value>
\t \t \t </list>
\t \t </property>
\t \t <property name="hibernateProperties">
\t \t \t <props>
\t \t \t \t <prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
\t \t \t \t <prop key="hibernate.hbm2ddl.auto">update</prop>
\t \t \t \t <prop key="temp.use_jdbc_metadata_defaults">false</prop>
\t \t \t \t <prop key="hibernate.archive.autodetection">class</prop>
\t \t \t \t <prop key="show_sql">true</prop>
\t \t \t \t <prop key="hibernate.format_sql">true</prop>
\t \t \t \t <prop key="hibernate.enable_lazy_load_no_trans">true</prop>
\t \t \t </props>
\t \t </property>
\t \t <property name="packagesToScan">
\t \t \t <array>
\t \t \t \t <value>com.prototype2.model.assessment</value>
\t \t \t \t <value>com.prototype2.model.user</value>
\t \t \t \t <value>com.prototype2.model.scores</value>
\t \t \t \t <value>com.prototype2.model.business</value>
\t \t \t \t <value>com.prototype2.dao.factory</value>
\t \t \t \t <value>com.prototype2.dao.user</value>
\t \t \t \t <value>com.prototype2.dao.testadministration</value>
\t \t \t \t <value>com.prototype2.service.user</value>
\t \t \t \t <value>com.prototype2.service.testadministration</value>
\t \t \t </array>
\t \t </property>
\t </bean>
\t <bean id="transactionManager"
\t \t class="org.springframework.orm.hibernate4.HibernateTransactionManager">
\t \t <property name="sessionFactory" ref="sfhbmSessionFactory" />
\t </bean>
\t <tx:annotation-driven transaction-manager="transactionManager" />
\t
<context:component-scan base-package="com.prototype2.model.assessment,
com.prototype2.model.user,
com.prototype2.model.scores,
com.prototype2.model.business,
com.prototype2.dao.factory,
com.prototype2.dao.user,
com.prototype2.dao.testadministration,
\t com.prototype2.service.user,
com.prototype2.service.testadministration"/>
\t <!-- DAO beans -->
\t <bean id="userDao" class="com.prototype2.dao.user.UserDaoImpl">
\t \t <property name="sessionFactory" ref="sfhbmSessionFactory" />
\t </bean>
\t <bean id="businessDao" class="com.prototype2.dao.user.BusinessDaoImpl">
\t \t <property name="sessionFactory" ref="sfhbmSessionFactory" />
\t </bean>
\t
\t <bean id="testTypeDao" class="com.prototype2.dao.testadministration.TestTypeDaoImpl">
\t \t <property name="sessionFactory" ref="sfhbmSessionFactory" />
\t </bean>
\t <!-- Service beans -->
\t <bean id="auService" class="com.prototype2.service.user.AdminUserServiceImpl">
\t \t <property name="userDao" ref="userDao" />
\t </bean>
\t <bean id="businessService" class="com.prototype2.service.user.BusinessServiceImpl">
\t \t <property name="businessDao" ref="businessDao" />
\t </bean>
\t
\t <bean id="testTypeService" class="com.prototype2.service.testadministration.TestTypeServiceImpl">
\t \t <property name="testTypeDao" ref="testTypeDao" />
\t </bean>
\t <!-- validation -->
\t <mvc:annotation-driven validator="validator" />
\t <bean id="validator"
\t \t class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">
\t \t <property name="providerClass" value="org.hibernate.validator.HibernateValidator" />
\t </bean>
</beans>
UPDATE: Вкладыш не было найдено ни с SQL запросом, веб-просмотра или тестирования JUnit. Ниже тест JUnit:
package com.prototype2.test.service;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.ArrayList;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.prototype2.model.assessment.TestType;
import com.prototype2.model.assessment.TestUnitType;
import com.prototype2.service.testadministration.TestTypeService;
import com.prototype2.test.testrunner.TestSS;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:AssessmentAdmin-servlet.xml")
public class TestUnitServiceCreateTTTest
{
@Autowired
private TestTypeService testTypeService;
private List<TestUnitType> blist = new ArrayList<TestUnitType>();
private int originalTTCount=0;
private int newTTCount=0;
@Before
public void prepTestType()
{
TestSS.getLogger().info("testGetTuts");
blist = testTypeService.getTestUnitTypes(TestSS.getBusiness().getId());
originalTTCount=testTypeService.getTestTypes(TestSS.getBusiness().getId()).size();
TestSS.getLogger().debug("originalTTCount= "+originalTTCount);
}
@Test
public void testGetTTTuts()
{
try
{
TestType tt = new TestType();
tt.setBusiness(TestSS.getBusiness());
tt.setTestTypeName("Basic Personality Test");
tt.addAssociatedTestTypeTestUnitType(blist.get(0));
testTypeService.saveTestType(tt);
newTTCount=testTypeService.getTestTypes(TestSS.getBusiness().getId()).size();
TestSS.getLogger().info("newTTCount=" + newTTCount);
assertTrue(newTTCount>originalTTCount);
assertFalse(null==tt.getId());
} catch (Exception e)
{
TestSS.getLogger().error(e.getMessage(), e);
fail();
}
}
}
UPDATE: Журналы без, а затем с session.fluch. Обратите внимание, что вставка выполняется при включенном флажке. Опять же, я подчеркиваю, у меня есть эта проблема, будь то через тестовый пример junit для обслуживания или через веб-страницу и контроллер для обслуживания.
==========LOGS WITHOUT FLUSH ON DAO====================================== *******originalTTCount= 2 [DEBUG] 2015-08-16 14:52:11,511: jake.prototype2.model.assessment.TestType.sortTestUnitTypePosition(TestType.java:427) associatedTestUnitTypes size=0 [DEBUG] 2015-08-16 14:52:11,514: org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:226) Obtaining JDBC connection [DEBUG] 2015-08-16 14:52:11,514: com.mchange.v2.resourcepool.BasicResourcePool.trace(BasicResourcePool.java:1747) trace [email protected] [managed: 11, unused: 1, excluded: 0] (e.g. [email protected]) [DEBUG] 2015-08-16 14:52:11,515: org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:232) Obtained JDBC connection [DEBUG] 2015-08-16 14:52:11,515: org.hibernate.engine.transaction.spi.AbstractTransactionImpl.begin(AbstractTransactionImpl.java:160) begin [DEBUG] 2015-08-16 14:52:11,515: org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.doBegin(JdbcTransaction.java:69) initial autocommit status: true [DEBUG] 2015-08-16 14:52:11,516: org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.doBegin(JdbcTransaction.java:71) disabling autocommit [DEBUG] 2015-08-16 14:52:11,516: jake.prototype2.service.testadministration.TestTypeServiceImpl.saveTestType(TestTypeServiceImpl.java:71) Saving tt: Id before saving is null [DEBUG] 2015-08-16 14:52:11,517: jake.prototype2.dao.testadministration.TestTypeDaoImpl.saveNewTestType(TestTypeDaoImpl.java:137) Saving TT: TestType [id=null, testTypeName=Basic Personality [email protected]] With Test Type Test Unit Type Id=null TestUnitTypeId= 81Algebra One [DEBUG] 2015-08-16 14:52:11,518: org.hibernate.engine.jdbc.spi.SqlStatementLogger.logStatement(SqlStatementLogger.java:109) select nextval ('hibernate_sequence') [DEBUG] 2015-08-16 14:52:11,518: org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:226) Obtaining JDBC connection [DEBUG] 2015-08-16 14:52:11,520: org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:232) Obtained JDBC connection [DEBUG] 2015-08-16 14:52:11,524: org.hibernate.id.SequenceGenerator.generateHolder(SequenceGenerator.java:127) Sequence identifier generated: BasicHolder[java.lang.Long[1682]] [DEBUG] 2015-08-16 14:52:11,524: org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:131) Generated identifier: 1682, using strategy: org.hibernate.id.SequenceGenerator [DEBUG] 2015-08-16 14:52:11,525: org.hibernate.engine.jdbc.spi.SqlStatementLogger.logStatement(SqlStatementLogger.java:109) select nextval ('hibernate_sequence') [DEBUG] 2015-08-16 14:52:11,526: org.hibernate.id.SequenceGenerator.generateHolder(SequenceGenerator.java:127) Sequence identifier generated: BasicHolder[java.lang.Long[1683]] [DEBUG] 2015-08-16 14:52:11,527: org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:131) Generated identifier: 1683, using strategy: org.hibernate.id.SequenceGenerator [DEBUG] 2015-08-16 14:52:11,528: jake.prototype2.service.testadministration.TestTypeServiceImpl.saveTestType(TestTypeServiceImpl.java:74) Saving tt: Id after saving is1682 [DEBUG] 2015-08-16 14:52:11,528: org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(AbstractTransactionImpl.java:175) committing [DEBUG] 2015-08-16 14:52:11,529: org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.doCommit(JdbcTransaction.java:113) committed JDBC Connection [DEBUG] 2015-08-16 14:52:11,529: org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.releaseManagedConnection(JdbcTransaction.java:126) re-enabling autocommit [DEBUG] 2015-08-16 14:52:11,529: org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.releaseConnection(LogicalConnectionImpl.java:246) Releasing JDBC connection [DEBUG] 2015-08-16 14:52:11,530: com.mchange.v2.async.ThreadPoolAsynchronousRunner.postRunnable(ThreadPoolAsynchronousRunner.java:236) [email protected]: Adding task to queue -- com.mchange.[email protected]5ca15100 [DEBUG] 2015-08-16 14:52:11,530: com.mchange.v2.resourcepool.BasicResourcePool.trace(BasicResourcePool.java:1747) trace [email protected] [managed: 11, unused: 0, excluded: 0] (e.g. [email protected]) [DEBUG] 2015-08-16 14:52:11,531: org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.releaseConnection(LogicalConnectionImpl.java:264) Released JDBC connection [DEBUG] 2015-08-16 14:52:11,532: jake.prototype2.test.service.TestUnitServiceCreateTTTest.testGetTTTuts(TestUnitServiceCreateTTTest.java:54) *****finished service ================================================================================ ===================LOGS WITH FLUSH ON DAO======================================= *******originalTTCount= 2 [DEBUG] 2015-08-16 14:59:39,732: org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:226) Obtaining JDBC connection [DEBUG] 2015-08-16 14:59:39,732: com.mchange.v2.resourcepool.BasicResourcePool.trace(BasicResourcePool.java:1747) trace [email protected] [managed: 10, unused: 0, excluded: 0] (e.g. [email protected]) [DEBUG] 2015-08-16 14:59:39,733: org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:232) Obtained JDBC connection [DEBUG] 2015-08-16 14:59:39,733: org.hibernate.engine.transaction.spi.AbstractTransactionImpl.begin(AbstractTransactionImpl.java:160) begin [DEBUG] 2015-08-16 14:59:39,733: org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.doBegin(JdbcTransaction.java:69) initial autocommit status: true [DEBUG] 2015-08-16 14:59:39,734: org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.doBegin(JdbcTransaction.java:71) disabling autocommit [DEBUG] 2015-08-16 14:59:39,734: jake.prototype2.service.testadministration.TestTypeServiceImpl.saveTestType(TestTypeServiceImpl.java:71) Saving tt: Id before saving isnull [DEBUG] 2015-08-16 14:59:39,737: jake.prototype2.dao.testadministration.TestTypeDaoImpl.saveNewTestType(TestTypeDaoImpl.java:137) Saving TT: TestType [id=null, testTypeName=Basic Personality [email protected]] With Test Type Test Unit Type Id=null TestUnitTypeId= 81Algebra One [DEBUG] 2015-08-16 14:59:39,738: org.hibernate.engine.jdbc.spi.SqlStatementLogger.logStatement(SqlStatementLogger.java:109) select nextval ('hibernate_sequence') [DEBUG] 2015-08-16 14:59:39,739: org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:226) Obtaining JDBC connection [DEBUG] 2015-08-16 14:59:39,739: com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.java:587) acquire test -- pool size: 10; target_pool_size: 11; desired target? 11 [DEBUG] 2015-08-16 14:59:39,740: com.mchange.v2.resourcepool.BasicResourcePool.incrementPendingAcquires(BasicResourcePool.java:450) incremented pending_acquires: 2 [DEBUG] 2015-08-16 14:59:39,740: com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.<init>(BasicResourcePool.java:1788) Starting acquisition series. Incremented pending_acquires [2], attempts_remaining: 30 [DEBUG] 2015-08-16 14:59:39,741: com.mchange.v2.async.ThreadPoolAsynchronousRunner.postRunnable(ThreadPoolAsynchronousRunner.java:236) [email protected]: Adding task to queue -- com[email protected]46cf19d4 [DEBUG] 2015-08-16 14:59:39,741: com.mchange.v2.resourcepool.BasicResourcePool.incrementPendingAcquires(BasicResourcePool.java:450) incremented pending_acquires: 3 [DEBUG] 2015-08-16 14:59:39,742: com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.<init>(BasicResourcePool.java:1788) Starting acquisition series. Incremented pending_acquires [3], attempts_remaining: 30 [DEBUG] 2015-08-16 14:59:39,742: com.mchange.v2.async.ThreadPoolAsynchronousRunner.postRunnable(ThreadPoolAsynchronousRunner.java:236) [email protected]: Adding task to queue -- com[email protected]7fdc07fa [DEBUG] 2015-08-16 14:59:39,743: com.mchange.v2.resourcepool.BasicResourcePool.awaitAvailable(BasicResourcePool.java:1390) awaitAvailable(): [email protected] [DEBUG] 2015-08-16 14:59:39,743: com.mchange.v2.resourcepool.BasicResourcePool.trace(BasicResourcePool.java:1747) trace [email protected] [managed: 10, unused: 0, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledCo[email protected]) [DEBUG] 2015-08-16 14:59:39,800: com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:283) com.mchange.v2.c3p0.imp[email protected]1fbcc531.acquireResource() returning. [DEBUG] 2015-08-16 14:59:39,801: com.mchange.v2.resourcepool.BasicResourcePool.trace(BasicResourcePool.java:1747) trace [email protected] [managed: 11, unused: 1, excluded: 0] (e.g. [email protected]) [DEBUG] 2015-08-16 14:59:39,801: com.mchange.v2.resourcepool.BasicResourcePool._decrementPendingAcquires(BasicResourcePool.java:471) decremented pending_acquires: 2 [DEBUG] 2015-08-16 14:59:39,801: com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1825) Acquisition series terminated successfully. Decremented pending_acquires [2], attempts_remaining: 30 [DEBUG] 2015-08-16 14:59:39,806: com.mchange.v2.resourcepool.BasicResourcePool.trace(BasicResourcePool.java:1747) trace [email protected] [managed: 11, unused: 0, excluded: 0] (e.g. [email protected]) [DEBUG] 2015-08-16 14:59:39,809: org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:232) Obtained JDBC connection [DEBUG] 2015-08-16 14:59:39,816: org.hibernate.id.SequenceGenerator.generateHolder(SequenceGenerator.java:127) Sequence identifier generated: BasicHolder[java.lang.Long[1679]] [DEBUG] 2015-08-16 14:59:39,817: org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:131) Generated identifier: 1679, using strategy: org.hibernate.id.SequenceGenerator [DEBUG] 2015-08-16 14:59:39,818: org.hibernate.engine.jdbc.spi.SqlStatementLogger.logStatement(SqlStatementLogger.java:109) select nextval ('hibernate_sequence') [DEBUG] 2015-08-16 14:59:39,819: org.hibernate.id.SequenceGenerator.generateHolder(SequenceGenerator.java:127) Sequence identifier generated: BasicHolder[java.lang.Long[1680]] [DEBUG] 2015-08-16 14:59:39,820: org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:131) Generated identifier: 1680, using strategy: org.hibernate.id.SequenceGenerator [DEBUG] 2015-08-16 14:59:39,821: org.hibernate.event.internal.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:149) Processing flush-time cascades [DEBUG] 2015-08-16 14:59:39,822: org.hibernate.event.internal.AbstractFlushingEventListener.prepareCollectionFlushes(AbstractFlushingEventListener.java:189) Dirty checking collections [DEBUG] 2015-08-16 14:59:39,823: org.hibernate.engine.internal.Collections.processReachableCollection(Collections.java:194) Collection found: [jake.prototype2.model.assessment.TestType.associatedFullTests#1679], was: [<unreferenced>] (initialized) [DEBUG] 2015-08-16 14:59:39,824: org.hibernate.engine.internal.Collections.processReachableCollection(Collections.java:194) Collection found: [jake.prototype2.model.assessment.TestType.associatedTestTypeTestUnitTypes#1679], was: [<unreferenced>] (initialized) [DEBUG] 2015-08-16 14:59:39,824: org.hibernate.engine.internal.Collections.processReachableCollection(Collections.java:194) Collection found: [jake.prototype2.model.assessment.TestType.associatedUsers#1679], was: [<unreferenced>] (initialized) [DEBUG] 2015-08-16 14:59:39,825: org.hibernate.event.internal.AbstractFlushingEventListener.logFlushResults(AbstractFlushingEventListener.java:123) Flushed: 2 insertions, 0 updates, 0 deletions to 2 objects [DEBUG] 2015-08-16 14:59:39,825: org.hibernate.event.internal.AbstractFlushingEventListener.logFlushResults(AbstractFlushingEventListener.java:130) Flushed: 3 (re)creations, 0 updates, 0 removals to 3 collections [DEBUG] 2015-08-16 14:59:39,826: org.hibernate.internal.util.EntityPrinter.toString(EntityPrinter.java:114) Listing entities: [DEBUG] 2015-08-16 14:59:39,826: org.hibernate.internal.util.EntityPrinter.toString(EntityPrinter.java:121) jake.prototype2.model.assessment.TestType{business=jake.prototype2.model.business.Business#1, created=null, testTypeName=Basic Personality Test, associatedUsers=[], id=1679, updated=2015-08-16 14:59:39.818, associatedFullTests=[], associatedTestTypeTestUnitTypes=[jake.prototype2.model.assessment.TestTypeTestUnitType#1680]} [DEBUG] 2015-08-16 14:59:39,827: org.hibernate.internal.util.EntityPrinter.toString(EntityPrinter.java:121) jake.prototype2.model.assessment.TestTypeTestUnitType{positionInTest=1, testUnitType=jake.prototype2.model.assessment.TestUnitType#81, business=jake.prototype2.model.business.Business#1, created=null, testType=jake.prototype2.model.assessment.TestType#1679, id=1680, updated=Sun Aug 16 14:59:39 PDT 2015} [DEBUG] 2015-08-16 14:59:39,828: org.hibernate.engine.jdbc.spi.SqlStatementLogger.logStatement(SqlStatementLogger.java:109) insert into TestType (businessId, created, testTypeName, updated, id) values (?, ?, ?, ?, ?) [DEBUG] 2015-08-16 14:59:39,842: org.hibernate.engine.jdbc.spi.SqlStatementLogger.logStatement(SqlStatementLogger.java:109) insert into TestTypeTestUnitType (businessId, created, positionInTest, TestTypeId, TestUnitTypeId, updated, id) values (?, ?, ?, ?, ?, ?, ?) [DEBUG] 2015-08-16 14:59:39,868: jake.prototype2.service.testadministration.TestTypeServiceImpl.saveTestType(TestTypeServiceImpl.java:74) Saving tt: Id after saving is1679 [DEBUG] 2015-08-16 14:59:39,868: org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(AbstractTransactionImpl.java:175) committing [DEBUG] 2015-08-16 14:59:39,869: org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.doCommit(JdbcTransaction.java:113) committed JDBC Connection [DEBUG] 2015-08-16 14:59:39,869: org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.releaseManagedConnection(JdbcTransaction.java:126) re-enabling autocommit [DEBUG] 2015-08-16 14:59:39,869: org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.releaseConnection(LogicalConnectionImpl.java:246) Releasing JDBC connection [DEBUG] 2015-08-16 14:59:39,870: com.mchange.v2.async.ThreadPoolAsynchronousRunner.postRunnable(ThreadPoolAsynchronousRunner.java:236) [email protected]: Adding task to queue -- com.mchange.[email protected]73e16fb6 [DEBUG] 2015-08-16 14:59:39,870: com.mchange.v2.resourcepool.BasicResourcePool.trace(BasicResourcePool.java:1747) trace [email protected] [managed: 11, unused: 0, excluded: 0] (e.g. [email protected]) [DEBUG] 2015-08-16 14:59:39,871: org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.releaseConnection(LogicalConnectionImpl.java:264) Released JDBC connection [DEBUG] 2015-08-16 14:59:39,871: jake.prototype2.test.service.TestUnitServiceCreateTTTest.testGetTTTuts(TestUnitServiceCreateTTTest.java:54) *****finished service
Я бы очень хотел, чтобы удалить свой программный флеш и следовать пружинным конвенциям. Любая помощь, совет или объяснение было бы глубоко признателен
флеш() не фиксируется. Никогда. Ты запутываешься и совершаешь. Что вы на самом деле ожидаете, когда не будете четко промываться, и что происходит вместо этого? –
Я понимаю, что флеш не фиксирует. Я ожидаю, что рекомендации по весенней сделке будут совершены после выхода метода dao. Тем не менее, он не фиксируется, если я программно не скрываю. – Jake
Чтобы быть более явным, я сохраняю новый родительский элемент вместе с некоторыми новыми дочерними элементами (т. Е. Новые вставки в отношениях один-много), а также новые отношения с существующими дочерними элементами для нового родителя. Мне нужно, чтобы это произошло, как только вызывается session.save, но это происходит не до тех пор, пока не будет вызван session.flush. – Jake