Hi
I just would like to know whether the following approach in working with proxies/lazy initialization is correct/possible:
1. Persistent objects are loaded by a worker thread. Collections are lazy="true"
2. The loaded object is passed to a SWING user interface
3. The UI accesses the object
4. The object is passed back to the worker thread which takes care of persitence details
When another thread (in my case the AWT event thread) than the one which initially loaded the object using Hibernate accesses a (lazy) collection, will there be possible problems?
I want all persistence details be done by the worker thread in order to keep the UI responsve. Or is there a way to have Hibernate generate synchronized collection proxies that are thread safe?
Thank you for any help
--Bruno
Hibernate version: 3.0.5
Mapping documents:
Code:
<hibernate-mapping package="ch.afp.data">
<class name="Person" table="People">
<id name="ID" type="long" unsaved-value="null">
<column name="ID" not-null="true"/>
<generator class="sequence">
<param name="sequence">S_People</param>
</generator>
</id>
<property name="lastName" column="LastName" not-null="true"/>
<property name="firstName" column="FirstName" not-null="true"/>
<!-- much more properties here -->
<set name="businessTransactions" table="BusTxns" lazy="true" cascade="all-delete-orphan">
<key column="PID"/>
<one-to-many class="BusinessTransaction"/>
</set>
</class>
</hibernate-mapping>
Name and version of the database you are using: PostgreSQL 8[/code]