[hibernate-commits] Hibernate SVN: r10396 - trunk/Hibernate3/test/org/hibernate/test/propertyref
hibernate-commits at lists.jboss.org
hibernate-commits at lists.jboss.org
Fri Sep 1 09:48:04 EDT 2006
Author: steve.ebersole at jboss.com
Date: 2006-09-01 09:48:02 -0400 (Fri, 01 Sep 2006)
New Revision: 10396
Modified:
trunk/Hibernate3/test/org/hibernate/test/propertyref/Person.hbm.xml
trunk/Hibernate3/test/org/hibernate/test/propertyref/Person.java
trunk/Hibernate3/test/org/hibernate/test/propertyref/PropertyRefTest.java
Log:
added test of simple bag keyed via property-ref
Modified: trunk/Hibernate3/test/org/hibernate/test/propertyref/Person.hbm.xml
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/propertyref/Person.hbm.xml 2006-09-01 13:41:58 UTC (rev 10395)
+++ trunk/Hibernate3/test/org/hibernate/test/propertyref/Person.hbm.xml 2006-09-01 13:48:02 UTC (rev 10396)
@@ -21,40 +21,35 @@
<hibernate-mapping package="org.hibernate.test.propertyref">
<class name="Person">
-
<id name="id">
<generator class="hilo"/>
</id>
-
+
<property name="name" length="100"/>
-
- <one-to-one name="address"
- property-ref="person"
- cascade="all"
- fetch="join"/>
-
- <set name="accounts"
- inverse="true">
- <key column="userId"
- property-ref="userId"/>
+ <property name="userId" column="person_userid" length="8" unique="true"/>
+
+ <one-to-one name="address" property-ref="person" cascade="all" fetch="join"/>
+
+ <set name="accounts" inverse="true">
+ <key column="userId" property-ref="userId"/>
<one-to-many class="Account"/>
</set>
-
- <property name="userId" column="person_userid" length="8" unique="true"/>
-
- </class>
+ <bag name="systems" table="USER_SYSTEM" lazy="false" inverse="false" cascade="all">
+ <key column="USER_ID" property-ref="userId" />
+ <element type="string" column="SYSTEM" />
+ </bag>
+ </class>
+
<class name="Address">
-
<id name="id">
<generator class="hilo"/>
</id>
-
+
<property name="address" length="300"/>
<property name="zip" length="5"/>
<property name="country" length="25"/>
<many-to-one name="person" unique="true" not-null="true"/>
-
</class>
<class name="Account">
Modified: trunk/Hibernate3/test/org/hibernate/test/propertyref/Person.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/propertyref/Person.java 2006-09-01 13:41:58 UTC (rev 10395)
+++ trunk/Hibernate3/test/org/hibernate/test/propertyref/Person.java 2006-09-01 13:48:02 UTC (rev 10396)
@@ -3,6 +3,8 @@
import java.util.HashSet;
import java.util.Set;
+import java.util.List;
+import java.util.ArrayList;
/**
* @author gavin
@@ -13,6 +15,8 @@
private Address address;
private String userId;
private Set accounts = new HashSet();
+ private List systems = new ArrayList();
+
/**
* @return Returns the userId.
*/
@@ -73,4 +77,12 @@
public void setAccounts(Set accounts) {
this.accounts = accounts;
}
+
+ public List getSystems() {
+ return systems;
+ }
+
+ public void setSystems(List systems) {
+ this.systems = systems;
+ }
}
Modified: trunk/Hibernate3/test/org/hibernate/test/propertyref/PropertyRefTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/propertyref/PropertyRefTest.java 2006-09-01 13:41:58 UTC (rev 10395)
+++ trunk/Hibernate3/test/org/hibernate/test/propertyref/PropertyRefTest.java 2006-09-01 13:48:02 UTC (rev 10396)
@@ -26,7 +26,40 @@
public PropertyRefTest(String str) {
super(str);
}
-
+
+ public void testNonLazyBagKeyPropertyRef() {
+ Session s = openSession();
+ Transaction t = s.beginTransaction();
+ Person p = new Person();
+ p.setName( "Steve" );
+ p.setUserId( "steve" );
+ p.getSystems().add( "QA" );
+ p.getSystems().add( "R&D" );
+ s.persist( p );
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ s.createQuery( "from Person" ).list();
+ s.clear();
+ s.createSQLQuery( "select {p.*} from Person {p}" )
+ .addEntity( "p", Person.class.getName() )
+ .list();
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ List results = s.createQuery( "from Person" ).list();
+ Iterator itr = results.iterator();
+ while ( itr.hasNext() ) {
+ s.delete( itr.next() );
+ }
+ t.commit();
+ s.close();
+ }
+
public void testManyToManyPropertyRef() {
// prepare some test data relating to the Group->Person many-to-many association
Session s = openSession();
@@ -228,5 +261,9 @@
cfg.setProperty(Environment.DEFAULT_BATCH_FETCH_SIZE, "1");
cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
}
+
+ public String getCacheConcurrencyStrategy() {
+ return null;
+ }
}
More information about the hibernate-commits
mailing list