Hazırda Bekletme 4 ve Yay İşlemlerini kullanan bir Spring 3.2 uygulamasına sahibim. Tüm yöntemler harika çalışıyordu ve varlıkları kaydetmek veya almak için veritabanına doğru bir şekilde erişebiliyordum. Sonra, bazı çoklu tanıtıldı ve her iplik ben hazırda aşağıdaki hatayı başlamıştı db erişen beri:Yay İşlemleri ve hibernate.current_session_context_class
org.hibernate.HibernateException: Illegal attempt to associate a collection with two open sessions
benim hazırda yapılandırmasına <prop key="hibernate.current_session_context_class">thread</prop>
eklemek ettik Web'den okumak, ama artık her zaman ben almak db erişmeye çalıştığınızda:
@Transactional
not eklenmiş Ancak
org.hibernate.HibernateException: saveOrUpdate is not valid without active transaction
ve tüm <prop key="hibernate.current_session_context_class">thread</prop>
ait eklenti önce iyi çalışıyordu.
Yöntemler, Transactional ile açıklanmasına rağmen neden işlem yok? Bu sorunu nasıl çözebilirim?
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">
<!-- Hibernate session factory -->
<bean
id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean" >
<property name="dataSource" >
<ref bean="dataSource" />
</property>
<property name="hibernateProperties" >
<props>
<prop key="hibernate.hbm2ddl.auto">create</prop>
<prop key="hibernate.dialect" >org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.current_session_context_class">thread</prop>
</props>
</property>
<property name="annotatedClasses" >
<list>
...
</list>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<tx:annotation-driven transaction-manager="transactionManager"/>
Tamam, eski yapılandırmayı geri yükledim, ancak şimdi, "org.hibernate.HibernateException: Yasadışı girişimi, çoklu açıklamayla birlikte gelen iki açık oturumla ilişkilendirmek için nasıl" çözebilirim? Temel olarak iş parçacığım var ve her ikisi de bir koleksiyon içeren aynı nesne üzerinde bir 'save()' işlemi yapmaya çalışırlar. Belki de bu durumdan kaçınmalı ve bunlardan sadece birini yapmalı mıyım? – user1781028
Neden birden çok ileti dizisi tarafından kaydedilen tek bir nesneye sahipsiniz. –
Tamam Kayıt işlemlerinden birini kaldırdım. Ama ya bazı özel nedenlerle, ikisine de gerçekten ihtiyacım varsa? – user1781028