Hibernate version:
3.2.0 GA
Mapping documents:
Tournoi.hbm.xml
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin 2.2
http://boss.bekk.no/boss/middlegen/
http://www.hibernate.org/
-->
<class
name="com.pescorer.business.Tournoi"
table="TOURNOI"
lazy="false"
>
<id
name="numero"
type="java.lang.Long"
column="NUMERO"
>
<generator class="native" />
</id>
<property
name="type"
type="java.lang.Integer"
column="TYPE"
not-null="true"
/>
<!-- Associations -->
<!-- bi-directional one-to-many association to Participant -->
<set
name="participants"
lazy="true"
inverse="true"
cascade="all"
>
<key>
<column name="NUM_TOURNOI" />
</key>
<one-to-many
class="com.pescorer.business.Participant"
/>
</set>
<!-- bi-directional one-to-one association to Championnat -->
<one-to-one
name="championnat"
class="com.pescorer.business.Championnat"
outer-join="auto"
/>
<!-- bi-directional one-to-many association to Match -->
<set
name="matches"
lazy="true"
inverse="true"
cascade="all"
order-by="numero asc"
>
<key>
<column name="NUM_TOURNOI" />
</key>
<one-to-many
class="com.pescorer.business.Match"
/>
</set>
<!-- bi-directional one-to-one association to Coupe -->
<one-to-one
name="coupe"
class="com.pescorer.business.Coupe"
outer-join="auto"
/>
<!-- bi-directional one-to-many association to Classement -->
<set
name="classements"
lazy="true"
inverse="true"
cascade="all"
>
<key>
<column name="NUM_TOURNOI" />
</key>
<one-to-many
class="com.pescorer.business.Classement"
/>
</set>
<!-- bi-directional many-to-one association to Saison -->
<many-to-one
name="saison"
class="com.pescorer.business.Saison"
not-null="true"
>
<column name="NUM_SAISON" />
</many-to-one>
</class>
</hibernate-mapping>
Match.hbm.xml
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin 2.2
http://boss.bekk.no/boss/middlegen/
http://www.hibernate.org/
-->
<class
name="com.pescorer.business.Match"
table="MATCH"
lazy="false"
>
<id
name="numero"
type="java.lang.Long"
column="NUMERO"
>
<generator class="native" />
</id>
<property
name="nbButs1"
type="java.lang.Integer"
column="NB_BUTS1"
/>
<property
name="nbButs2"
type="java.lang.Integer"
column="NB_BUTS2"
/>
<property
name="prolongations"
type="java.lang.Boolean"
column="PROLONGATIONS"
/>
<property
name="penalties"
type="java.lang.Boolean"
column="PENALTIES"
/>
<property
name="nbPenalties1"
type="java.lang.Integer"
column="NB_PENALTIES1"
/>
<property
name="nbPenalties2"
type="java.lang.Integer"
column="NB_PENALTIES2"
/>
<property
name="groupe"
type="java.lang.Integer"
column="GROUPE"
/>
<property
name="journee"
type="java.lang.Integer"
column="JOURNEE"
/>
<property
name="tour"
type="java.lang.Integer"
column="TOUR"
/>
<property
name="forfait"
type="java.lang.Boolean"
column="FORFAIT"
not-null="true"
/>
<property
name="verrouille"
type="java.lang.Boolean"
column="VERROUILLE"
not-null="true"
/>
<!-- Associations -->
<!-- bi-directional many-to-one association to Tournoi -->
<many-to-one
name="tournoi"
class="com.pescorer.business.Tournoi"
not-null="true"
>
<column name="NUM_TOURNOI" />
</many-to-one>
<!-- bi-directional many-to-one association to UtilisateurParticipant -->
<many-to-one
name="utilisateurParticipantByNumUtilisateurParticipant1"
class="com.pescorer.business.UtilisateurParticipant"
not-null="true"
>
<column name="NUM_UTILISATEUR_PARTICIPANT1" />
</many-to-one>
<!-- bi-directional many-to-one association to UtilisateurParticipant -->
<many-to-one
name="utilisateurParticipantByNumUtilisateurParticipant2"
class="com.pescorer.business.UtilisateurParticipant"
not-null="true"
>
<column name="NUM_UTILISATEUR_PARTICIPANT2" />
</many-to-one>
<!-- bi-directional one-to-many association to Stat -->
<set
name="stats"
lazy="true"
inverse="true"
cascade="all"
>
<key>
<column name="NUM_MATCH" />
</key>
<one-to-many
class="com.pescorer.business.Stat"
/>
</set>
</class>
</hibernate-mapping>
Name and version of the database you are using:
HSQLDB 1.8.0
I have a Tournoi instance in memory with a collection of Matches. This instance is persistent (session.save(tournoi) has been done).
Then, I retrieve a new collection of matches with a Criteria query.
I make some changes in some matches of that collection and if I write the following :
Code:
List matches = tournoi.getMatches();
...
Match match = ... (Match) iterator.next();
System.out.println(match.toString());
I still have the old match. I must load the tournoi again from the DB to get the up-to-date collection.
Is any way to synchronize this collection ?
I know that a question almost similar had been asked but I was wondering if it has something to do with detached instances...
It seems strange that there is not any automatic process managed by Hibernate.