Browse Source

Remapped persistent classes using XML metadata instead of annotations.

peter_backlund 18 years ago
parent
commit
ce5373bc2d

+ 8
- 8
dddsample/src/main/java/se/citerus/dddsample/util/SampleDataGenerator.java View File

@@ -158,18 +158,18 @@ public class SampleDataGenerator implements ServletContextListener {
158 158
     executeUpdate(jdbcTemplate, itinerarySql, itineraryArgs);
159 159
 
160 160
     String legSql =
161
-      "insert into Leg (id, itinerary_id, carrierMovement_id, from_id, to_id) " +
162
-      "values (?,?,?,?,?)";
161
+      "insert into Leg (id, itinerary_id, carrierMovement_id, from_id, to_id, leg_index) " +
162
+      "values (?,?,?,?,?,?)";
163 163
 
164 164
     Object [][] legArgs = {
165 165
       // Cargo 5: Hongkong - Melbourne - Stockholm - Helsinki
166
-      {1,1,10,3,2},
167
-      {2,1,11,2,1},
168
-      {3,1,11,1,5},
166
+      {1,1,10,3,2,0},
167
+      {2,1,11,2,1,1},
168
+      {3,1,11,1,5,2},
169 169
       // Cargo 6: Hamburg - Stockholm - Chicago - Tokyo
170
-      {4,2,12,6,1},
171
-      {5,2,13,1,7},
172
-      {6,2,14,7,4}
170
+      {4,2,12,6,1,0},
171
+      {5,2,13,1,7,1},
172
+      {6,2,14,7,4,2}
173 173
     };
174 174
     executeUpdate(jdbcTemplate, legSql, legArgs);
175 175
   }

+ 6
- 9
dddsample/src/main/resources/hibernate.cfg.xml View File

@@ -10,15 +10,12 @@
10 10
     <!-- Properties defined here are shared between test and production -->
11 11
     <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
12 12
     
13
-    <mapping class="se.citerus.dddsample.domain.Cargo"/>
14
-    <mapping class="se.citerus.dddsample.domain.TrackingId"/>
15
-    <mapping class="se.citerus.dddsample.domain.Leg"/>
16
-    <mapping class="se.citerus.dddsample.domain.Itinerary"/>
17
-    <mapping class="se.citerus.dddsample.domain.Location"/>
18
-    <mapping class="se.citerus.dddsample.domain.HandlingEvent"/>
19
-    <mapping class="se.citerus.dddsample.domain.CarrierMovement"/>
20
-    <mapping class="se.citerus.dddsample.domain.CarrierMovementId"/>
21
-    <mapping class="se.citerus.dddsample.domain.UnLocode"/>
13
+    <mapping resource="se/citerus/dddsample/domain/Cargo.hbm.xml" />
14
+    <mapping resource="se/citerus/dddsample/domain/Itinerary.hbm.xml" />
15
+    <mapping resource="se/citerus/dddsample/domain/Leg.hbm.xml" />
16
+    <mapping resource="se/citerus/dddsample/domain/Location.hbm.xml" />
17
+    <mapping resource="se/citerus/dddsample/domain/CarrierMovement.hbm.xml" />
18
+    <mapping resource="se/citerus/dddsample/domain/HandlingEvent.hbm.xml" />
22 19
   </session-factory>
23 20
 
24 21
 </hibernate-configuration>

+ 19
- 0
dddsample/src/main/resources/se/citerus/dddsample/domain/Cargo.hbm.xml View File

@@ -0,0 +1,19 @@
1
+<?xml version="1.0"?>
2
+
3
+<!DOCTYPE hibernate-mapping PUBLIC
4
+  "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
5
+  "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
6
+
7
+<hibernate-mapping default-access="field">
8
+  <class name="se.citerus.dddsample.domain.Cargo" table="Cargo">
9
+    <id name="id" column="id">
10
+      <generator class="org.hibernate.id.IdentityGenerator"/>
11
+    </id>
12
+    <component name="trackingId" unique="true" update="false">
13
+      <property name="id" column="tracking_id"/>
14
+    </component>
15
+    <many-to-one name="origin" column="origin_id" cascade="none" fetch="join" update="false"/>
16
+    <many-to-one name="destination" column="destination_id" cascade="none" fetch="join"/>
17
+    <many-to-one name="itinerary" column="itinerary_id" cascade="all" fetch="join"/>
18
+  </class>
19
+</hibernate-mapping>

+ 18
- 0
dddsample/src/main/resources/se/citerus/dddsample/domain/CarrierMovement.hbm.xml View File

@@ -0,0 +1,18 @@
1
+<?xml version="1.0"?>
2
+
3
+<!DOCTYPE hibernate-mapping PUBLIC
4
+  "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
5
+  "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
6
+
7
+<hibernate-mapping default-access="field">
8
+  <class name="se.citerus.dddsample.domain.CarrierMovement" table="CarrierMovement">
9
+    <id name="id" column="id">
10
+      <generator class="org.hibernate.id.IdentityGenerator"/>
11
+    </id>
12
+    <component name="carrierMovementId" update="false">
13
+      <property name="id" column="carrier_movement_id" not-null="true"/>
14
+    </component>
15
+    <many-to-one name="from" column="from_id" not-null="true" update="false"/>
16
+    <many-to-one name="to" column="to_id" not-null="true" update="false"/>
17
+  </class>
18
+</hibernate-mapping>

+ 24
- 0
dddsample/src/main/resources/se/citerus/dddsample/domain/HandlingEvent.hbm.xml View File

@@ -0,0 +1,24 @@
1
+<?xml version="1.0"?>
2
+
3
+<!DOCTYPE hibernate-mapping PUBLIC
4
+  "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
5
+  "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
6
+
7
+<hibernate-mapping default-access="field">
8
+  <class name="se.citerus.dddsample.domain.HandlingEvent" table="HandlingEvent">
9
+    <id name="id" column="id">
10
+      <generator class="org.hibernate.id.IdentityGenerator"/>
11
+    </id>
12
+    <many-to-one name="carrierMovement" column="carrierMovement_id" not-null="false" cascade="none"/>
13
+    <many-to-one name="location" column="location_id" not-null="true" cascade="none"/>
14
+    <many-to-one name="cargo" column="cargo_id" not-null="true" cascade="none"/>
15
+    <property name="completionTime" column="completionTime" not-null="true"/>
16
+    <property name="registrationTime" column="registrationTime" not-null="true"/>
17
+    <property name="type" column="type" not-null="true">
18
+      <type name="org.hibernate.type.EnumType">
19
+        <param name="enumClass">se.citerus.dddsample.domain.HandlingEvent$Type</param>
20
+        <param name="type">12</param><!-- 12 is java.sql.Types.VARCHAR -->
21
+      </type>
22
+    </property>
23
+  </class>
24
+</hibernate-mapping>

+ 18
- 0
dddsample/src/main/resources/se/citerus/dddsample/domain/Itinerary.hbm.xml View File

@@ -0,0 +1,18 @@
1
+<?xml version="1.0"?>
2
+
3
+<!DOCTYPE hibernate-mapping PUBLIC
4
+  "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
5
+  "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
6
+
7
+<hibernate-mapping default-access="field">
8
+  <class name="se.citerus.dddsample.domain.Itinerary" table="Itinerary">
9
+    <id name="id" column="id">
10
+      <generator class="org.hibernate.id.IdentityGenerator"/>
11
+    </id>
12
+    <list name="legs" cascade="all">
13
+      <key column="itinerary_id"/>
14
+      <index column="leg_index"/>
15
+      <one-to-many class="se.citerus.dddsample.domain.Leg"/>
16
+    </list>
17
+  </class>
18
+</hibernate-mapping>

+ 16
- 0
dddsample/src/main/resources/se/citerus/dddsample/domain/Leg.hbm.xml View File

@@ -0,0 +1,16 @@
1
+<?xml version="1.0"?>
2
+
3
+<!DOCTYPE hibernate-mapping PUBLIC
4
+  "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
5
+  "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
6
+
7
+<hibernate-mapping default-access="field">
8
+  <class name="se.citerus.dddsample.domain.Leg" table="Leg">
9
+    <id name="id" column="id">
10
+      <generator class="org.hibernate.id.IdentityGenerator"/>
11
+    </id>
12
+    <many-to-one name="carrierMovement" column="carrierMovement_id" fetch="join" cascade="none"/>
13
+    <many-to-one name="from" column="from_id" fetch="join" cascade="none"/>
14
+    <many-to-one name="to" column="to_id" fetch="join" cascade="none"/>
15
+  </class>
16
+</hibernate-mapping>

+ 17
- 0
dddsample/src/main/resources/se/citerus/dddsample/domain/Location.hbm.xml View File

@@ -0,0 +1,17 @@
1
+<?xml version="1.0"?>
2
+
3
+<!DOCTYPE hibernate-mapping PUBLIC
4
+  "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
5
+  "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
6
+
7
+<hibernate-mapping default-access="field">
8
+  <class name="se.citerus.dddsample.domain.Location" table="Location">
9
+    <id name="id" column="id">
10
+      <generator class="org.hibernate.id.IdentityGenerator"/>
11
+    </id>
12
+    <component name="unLocode" unique="true" update="false">
13
+      <property name="unlocode" column="unlocode" not-null="true"/>
14
+    </component>
15
+    <property name="name" column="name" not-null="true"/>
16
+  </class>
17
+</hibernate-mapping>