Author: mdryakhlenkov
Date: 2007-07-10 10:49:00 -0400 (Tue, 10 Jul 2007)
New Revision: 2368
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/bytecode/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/bytecode/Bean.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/bytecode/Bean.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/bytecode/BeanReflectionHelper.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/bytecode/ProxyBean.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cache/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cache/Item.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cache/Item.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cache/VersionedItem.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cascade/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cascade/Job.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cascade/Job.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cascade/JobBatch.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cascade/JobBatch.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/Customer.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/Customer.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/LineItem.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/LineItem.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/Order.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/Order.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/Product.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/Product.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/bag/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/bag/BagOwner.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/bag/Mappings.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/idbag/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/idbag/IdbagOwner.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/idbag/Mappings.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/list/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/list/ListOwner.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/list/Mappings.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/map/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/map/Child.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/map/Mappings.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/map/Parent.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/original/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/original/Email.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/original/Permission.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/original/User.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/original/UserPermissions.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/set/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/set/Child.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/set/Mappings.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/set/Parent.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/basic/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/basic/Employee.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/basic/Person.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/basic/User.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/basic/User.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/collection/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/collection/Definition.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/collection/LocalizedStrings.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/collection/Mappings.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/collection/Value.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/toone/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/toone/Address.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/toone/Document.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/toone/Mappings.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/toone/PersonalInfo.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/toone/User.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/compositeelement/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/compositeelement/Child.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/compositeelement/Parent.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/compositeelement/Parent.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/connections/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/connections/Other.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/connections/Silly.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/connections/Silly.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/criteria/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/criteria/Course.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/criteria/Enrolment.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/criteria/Enrolment.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/criteria/Student.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cuk/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cuk/Account.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cuk/Address.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cuk/Person.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cuk/Person.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cut/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cut/MonetoryAmount.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cut/MonetoryAmountUserType.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cut/Transaction.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cut/Transaction.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cut/types.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/deletetransient/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/deletetransient/Address.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/deletetransient/Person.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/deletetransient/Person.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/dialect/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/dialect/functional/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/dialect/functional/cache/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/dialect/functional/cache/TestInterSystemsFunctionsClass.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/dialect/functional/cache/TestInterSystemsFunctionsClass.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/discriminator/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/discriminator/Address.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/discriminator/Customer.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/discriminator/Employee.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/discriminator/Person.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/discriminator/Person.java
Modified:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/declaration/id/composite/v1/KeyManyToOneClass.hbm.xml
Log:
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/bytecode/Bean.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/bytecode/Bean.hbm.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/bytecode/Bean.hbm.xml 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,28 @@
+<?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 package="mapping.bytecode">
+
+ <class name="Bean">
+ <id name="someString" type="string">
+ <generator class="assigned"/>
+ </id>
+ <property name="someLong" type="long"
column="S_LONG_1" />
+ <property name="someInteger" type="int"
column="S_INT_1" />
+ <property name="someDate" type="timestamp"
column="S_DATE_1" />
+ <property name="somelong" type="long"
column="S_LONG_2" />
+ <property name="someint" type="int"
column="S_INT_2" />
+ <property name="someObject" type="serializable"
column="S_OBJ_1" />
+ </class>
+
+
+ <class name="ProxyBean" lazy="true">
+ <id name="someString" type="string">
+ <generator class="assigned"/>
+ </id>
+ <property name="someLong" type="long"
column="S_LONG_1" />
+ </class>
+
+</hibernate-mapping>
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/bytecode/Bean.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/bytecode/Bean.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/bytecode/Bean.java 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,78 @@
+package mapping.bytecode;
+
+import java.util.Date;
+import java.text.ParseException;
+
+/**
+ * @author Steve Ebersole
+ */
+public class Bean {
+ private String someString;
+ private Long someLong;
+ private Integer someInteger;
+ private Date someDate;
+ private long somelong;
+ private int someint;
+ private Object someObject;
+
+
+ public String getSomeString() {
+ return someString;
+ }
+
+ public void setSomeString(String someString) {
+ this.someString = someString;
+ }
+
+ public Long getSomeLong() {
+ return someLong;
+ }
+
+ public void setSomeLong(Long someLong) {
+ this.someLong = someLong;
+ }
+
+ public Integer getSomeInteger() {
+ return someInteger;
+ }
+
+ public void setSomeInteger(Integer someInteger) {
+ this.someInteger = someInteger;
+ }
+
+ public Date getSomeDate() {
+ return someDate;
+ }
+
+ public void setSomeDate(Date someDate) {
+ this.someDate = someDate;
+ }
+
+ public long getSomelong() {
+ return somelong;
+ }
+
+ public void setSomelong(long somelong) {
+ this.somelong = somelong;
+ }
+
+ public int getSomeint() {
+ return someint;
+ }
+
+ public void setSomeint(int someint) {
+ this.someint = someint;
+ }
+
+ public Object getSomeObject() {
+ return someObject;
+ }
+
+ public void setSomeObject(Object someObject) {
+ this.someObject = someObject;
+ }
+
+ public void throwException() throws ParseException {
+ throw new ParseException( "you asked for it...", 0 );
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/bytecode/BeanReflectionHelper.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/bytecode/BeanReflectionHelper.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/bytecode/BeanReflectionHelper.java 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,78 @@
+package mapping.bytecode;
+
+import org.hibernate.property.BasicPropertyAccessor;
+import org.hibernate.property.Getter;
+import org.hibernate.property.Setter;
+
+import java.util.Date;
+
+/**
+ * @author Steve Ebersole
+ */
+public class BeanReflectionHelper {
+
+ public static final Object[] TEST_VALUES = new Object[] {
+ "hello", new Long(1), new Integer(1), new Date(), new Long(1), new
Integer(1), new Object()
+ };
+
+ private static final String[] getterNames = new String[7];
+ private static final String[] setterNames = new String[7];
+ private static final Class[] types = new Class[7];
+
+ static {
+ BasicPropertyAccessor propertyAccessor = new BasicPropertyAccessor();
+ Getter getter = propertyAccessor.getGetter( Bean.class, "someString" );
+ Setter setter = propertyAccessor.getSetter( Bean.class, "someString" );
+ getterNames[0] = getter.getMethodName();
+ types[0] = getter.getReturnType();
+ setterNames[0] = setter.getMethodName();
+
+ getter = propertyAccessor.getGetter( Bean.class, "someLong" );
+ setter = propertyAccessor.getSetter( Bean.class, "someLong" );
+ getterNames[1] = getter.getMethodName();
+ types[1] = getter.getReturnType();
+ setterNames[1] = setter.getMethodName();
+
+ getter = propertyAccessor.getGetter( Bean.class, "someInteger" );
+ setter = propertyAccessor.getSetter( Bean.class, "someInteger" );
+ getterNames[2] = getter.getMethodName();
+ types[2] = getter.getReturnType();
+ setterNames[2] = setter.getMethodName();
+
+ getter = propertyAccessor.getGetter( Bean.class, "someDate" );
+ setter = propertyAccessor.getSetter( Bean.class, "someDate" );
+ getterNames[3] = getter.getMethodName();
+ types[3] = getter.getReturnType();
+ setterNames[3] = setter.getMethodName();
+
+ getter = propertyAccessor.getGetter( Bean.class, "somelong" );
+ setter = propertyAccessor.getSetter( Bean.class, "somelong" );
+ getterNames[4] = getter.getMethodName();
+ types[4] = getter.getReturnType();
+ setterNames[4] = setter.getMethodName();
+
+ getter = propertyAccessor.getGetter( Bean.class, "someint" );
+ setter = propertyAccessor.getSetter( Bean.class, "someint" );
+ getterNames[5] = getter.getMethodName();
+ types[5] = getter.getReturnType();
+ setterNames[5] = setter.getMethodName();
+
+ getter = propertyAccessor.getGetter( Bean.class, "someObject" );
+ setter = propertyAccessor.getSetter( Bean.class, "someObject" );
+ getterNames[6] = getter.getMethodName();
+ types[6] = getter.getReturnType();
+ setterNames[6] = setter.getMethodName();
+ }
+
+ public static String[] getGetterNames() {
+ return getterNames;
+ }
+
+ public static String[] getSetterNames() {
+ return setterNames;
+ }
+
+ public static Class[] getTypes() {
+ return types;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/bytecode/ProxyBean.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/bytecode/ProxyBean.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/bytecode/ProxyBean.java 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,31 @@
+package mapping.bytecode;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: Paul
+ * Date: Mar 9, 2007
+ * Time: 11:31:40 AM
+ * To change this template use File | Settings | File Templates.
+ */
+public class ProxyBean {
+ private String someString;
+ private long someLong;
+
+
+ public String getSomeString() {
+ return someString;
+ }
+
+ public void setSomeString(String someString) {
+ this.someString = someString;
+ }
+
+
+ public long getSomeLong() {
+ return someLong;
+ }
+
+ public void setSomeLong(long someLong) {
+ this.someLong = someLong;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cache/Item.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cache/Item.hbm.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cache/Item.hbm.xml 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,26 @@
+<?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
+ package="mapping.cache">
+
+ <class name="Item" table="Items">
+ <id name="id">
+ <generator class="increment"/>
+ </id>
+ <property name="name" not-null="true"/>
+ <property name="description" not-null="true"/>
+ </class>
+
+ <class name="VersionedItem" table="VersionedItems">
+ <id name="id">
+ <generator class="increment"/>
+ </id>
+ <version name="version" type="long"/>
+ <property name="name" not-null="true"/>
+ <property name="description" not-null="true"/>
+ </class>
+
+</hibernate-mapping>
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cache/Item.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cache/Item.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cache/Item.java 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,31 @@
+//$Id: Item.java 5686 2005-02-12 07:27:32Z steveebersole $
+package mapping.cache;
+
+
+/**
+ * @author Gavin King
+ */
+public class Item {
+ private Long id;
+ private String name;
+ private String description;
+
+ public String getDescription() {
+ return description;
+ }
+ public void setDescription(String description) {
+ this.description = description;
+ }
+ public Long getId() {
+ return id;
+ }
+ public void setId(Long id) {
+ this.id = id;
+ }
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cache/VersionedItem.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cache/VersionedItem.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cache/VersionedItem.java 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,16 @@
+package mapping.cache;
+
+/**
+ * @author Steve Ebersole
+ */
+public class VersionedItem extends Item {
+ private Long version;
+
+ public Long getVersion() {
+ return version;
+ }
+
+ public void setVersion(Long version) {
+ this.version = version;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cascade/Job.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cascade/Job.hbm.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cascade/Job.hbm.xml 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping SYSTEM
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
+
+<hibernate-mapping package="mapping.cascade">
+
+ <class name="Job" table="T_JOB">
+ <id name="id" column="JOB_ID">
+ <generator class="native"/>
+ </id>
+
+ <many-to-one name="batch" class="JobBatch"
cascade="none" column="BATCH_ID"/>
+
+ <property name="status" type="int" column="JOB_STATUS"
not-null="true"/>
+ <property name="processingInstructions" type="string"
column="PI" not-null="true"/>
+
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cascade/Job.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cascade/Job.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cascade/Job.java 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,53 @@
+// $Id: Job.java 6663 2005-05-03 20:55:31Z steveebersole $
+package mapping.cascade;
+
+/**
+ * Implementation of Job.
+ *
+ * @author Steve Ebersole
+ */
+public class Job {
+ private Long id;
+ private JobBatch batch;
+ private String processingInstructions;
+ private int status;
+
+ /** GCLIB constructor */
+ Job() {}
+
+ protected Job(JobBatch batch) {
+ this.batch = batch;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ /*package*/ void setId(Long id) {
+ this.id = id;
+ }
+
+ public JobBatch getBatch() {
+ return batch;
+ }
+
+ /*package*/ void setBatch(JobBatch batch) {
+ this.batch = batch;
+ }
+
+ public String getProcessingInstructions() {
+ return processingInstructions;
+ }
+
+ public void setProcessingInstructions(String processingInstructions) {
+ this.processingInstructions = processingInstructions;
+ }
+
+ public int getStatus() {
+ return status;
+ }
+
+ public void setStatus(int status) {
+ this.status = status;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cascade/JobBatch.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cascade/JobBatch.hbm.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cascade/JobBatch.hbm.xml 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping SYSTEM
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
+
+<hibernate-mapping package="mapping.cascade">
+
+ <class name="JobBatch" table="T_JOB_BATCH">
+ <id name="id" column="BATCH_ID">
+ <generator class="native"/>
+ </id>
+
+ <property name="batchDate" type="timestamp"
column="BATCH_DATE" not-null="true"/>
+
+ <set name="jobs" inverse="true" fetch="select"
lazy="true" cascade="all, refresh">
+ <key column="BATCH_ID"/>
+ <one-to-many class="Job"/>
+ </set>
+
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cascade/JobBatch.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cascade/JobBatch.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cascade/JobBatch.java 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,54 @@
+// $Id: JobBatch.java 6663 2005-05-03 20:55:31Z steveebersole $
+package mapping.cascade;
+
+import java.util.Date;
+import java.util.Set;
+import java.util.HashSet;
+
+/**
+ * Implementation of JobBatch.
+ *
+ * @author Steve Ebersole
+ */
+public class JobBatch {
+ private Long id;
+ private Date batchDate;
+ private Set jobs = new HashSet();
+
+ /** CGLIB constructor */
+ JobBatch() {}
+
+ public JobBatch(Date batchDate) {
+ this.batchDate = batchDate;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public Date getBatchDate() {
+ return batchDate;
+ }
+
+ public void setBatchDate(Date batchDate) {
+ this.batchDate = batchDate;
+ }
+
+ public Set getJobs() {
+ return jobs;
+ }
+
+ public void setJobs(Set jobs) {
+ this.jobs = jobs;
+ }
+
+ public Job createJob() {
+ Job job = new Job( this );
+ jobs.add( job );
+ return job;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/Customer.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/Customer.hbm.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/Customer.hbm.xml 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,37 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<!--
+
+ This mapping demonstrates how to map a collection
+ <key> to one of the primary key columns of an
+ associated child class with a composite key. This
+ is very useful for legacy data!
+
+-->
+
+<hibernate-mapping package="mapping.cid">
+
+ <class name="Customer">
+
+ <id name="customerId"
+ length="10">
+ <generator class="assigned"/>
+ </id>
+
+ <property name="name" not-null="true"
length="100"/>
+ <property name="address" not-null="true"
length="200"/>
+
+ <list name="orders"
+ inverse="true"
+ cascade="save-update">
+ <key column="customerId"/>
+ <index column="orderNumber"/>
+ <one-to-many class="Order"/>
+ </list>
+
+ </class>
+
+</hibernate-mapping>
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/Customer.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/Customer.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/Customer.java 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,73 @@
+//$Id: Customer.java 4806 2004-11-25 14:37:00Z steveebersole $
+package mapping.cid;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.GregorianCalendar;
+import java.math.BigDecimal;
+
+/**
+ * @author Gavin King
+ */
+public class Customer {
+ private String customerId;
+ private String name;
+ private String address;
+ private List orders = new ArrayList();
+ /**
+ * @return Returns the address.
+ */
+ public String getAddress() {
+ return address;
+ }
+ /**
+ * @param address The address to set.
+ */
+ public void setAddress(String address) {
+ this.address = address;
+ }
+ /**
+ * @return Returns the customerId.
+ */
+ public String getCustomerId() {
+ return customerId;
+ }
+ /**
+ * @param customerId The customerId to set.
+ */
+ public void setCustomerId(String customerId) {
+ this.customerId = customerId;
+ }
+ /**
+ * @return Returns the name.
+ */
+ public String getName() {
+ return name;
+ }
+ /**
+ * @param name The name to set.
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+ /**
+ * @return Returns the orders.
+ */
+ public List getOrders() {
+ return orders;
+ }
+ /**
+ * @param orders The orders to set.
+ */
+ public void setOrders(List orders) {
+ this.orders = orders;
+ }
+
+ public Order generateNewOrder(BigDecimal total) {
+ Order order = new Order(this);
+ order.setOrderDate( new GregorianCalendar() );
+ order.setTotal( total );
+
+ return order;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/LineItem.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/LineItem.hbm.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/LineItem.hbm.xml 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<!--
+
+ This mapping demonstrates
+
+ (1) composite keys and many-to-one associations on
+ composite keys
+
+ (2) use of insert="false" update="false" on an
+ association mapping, when the foreign key is
+ also part of the primary key
+
+-->
+
+<hibernate-mapping package="mapping.cid">
+
+ <class name="LineItem">
+
+ <composite-id name="id"
+ class="LineItem$Id">
+ <key-property name="customerId" length="10"/>
+ <key-property name="orderNumber"/>
+ <key-property name="productId" length="10"/>
+ </composite-id>
+
+ <property name="quantity"/>
+
+ <many-to-one name="order"
+ insert="false"
+ update="false"
+ not-null="true">
+ <column name="customerId"/>
+ <column name="orderNumber"/>
+ </many-to-one>
+
+ <many-to-one name="product"
+ insert="false"
+ update="false"
+ not-null="true"
+ column="productId"/>
+
+ </class>
+
+
+</hibernate-mapping>
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/LineItem.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/LineItem.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/LineItem.java 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,137 @@
+//$Id: LineItem.java 4806 2004-11-25 14:37:00Z steveebersole $
+package mapping.cid;
+
+import java.io.Serializable;
+
+/**
+ * @author Gavin King
+ */
+public class LineItem {
+ public static class Id implements Serializable {
+ private String customerId;
+ private int orderNumber;
+ private String productId;
+
+ public Id(String customerId, int orderNumber, String productId) {
+ this.customerId = customerId;
+ this.orderNumber = orderNumber;
+ this.productId = productId;
+ }
+ public Id() {}
+
+ /**
+ * @return Returns the customerId.
+ */
+ public String getCustomerId() {
+ return customerId;
+ }
+ /**
+ * @param customerId The customerId to set.
+ */
+ public void setCustomerId(String customerId) {
+ this.customerId = customerId;
+ }
+ /**
+ * @return Returns the productId.
+ */
+ public String getProductId() {
+ return productId;
+ }
+ /**
+ * @param productId The productId to set.
+ */
+ public void setProductId(String productId) {
+ this.productId = productId;
+ }
+ /**
+ * @return Returns the orderNumber.
+ */
+ public int getOrderNumber() {
+ return orderNumber;
+ }
+ /**
+ * @param orderNumber The orderNumber to set.
+ */
+ public void setOrderNumber(int orderNumber) {
+ this.orderNumber = orderNumber;
+ }
+ public int hashCode() {
+ return customerId.hashCode() + orderNumber + productId.hashCode();
+ }
+ public boolean equals(Object other) {
+ if (other instanceof Id) {
+ Id that = (Id) other;
+ return that.customerId.equals(this.customerId) &&
+ that.productId.equals(this.productId) &&
+ that.orderNumber == this.orderNumber;
+ }
+ else {
+ return false;
+ }
+ }
+ }
+
+ private Id id = new Id();
+ private int quantity;
+ private Order order;
+ private Product product;
+
+ public LineItem(Order o, Product p) {
+ this.order = o;
+ this.id.orderNumber = o.getId().getOrderNumber();
+ this.id.customerId = o.getId().getCustomerId();
+ this.id.productId = p.getProductId();
+ o.getLineItems().add(this);
+ }
+
+ public LineItem() {}
+
+ /**
+ * @return Returns the order.
+ */
+ public Order getOrder() {
+ return order;
+ }
+ /**
+ * @param order The order to set.
+ */
+ public void setOrder(Order order) {
+ this.order = order;
+ }
+ /**
+ * @return Returns the product.
+ */
+ public Product getProduct() {
+ return product;
+ }
+ /**
+ * @param product The product to set.
+ */
+ public void setProduct(Product product) {
+ this.product = product;
+ }
+ /**
+ * @return Returns the quantity.
+ */
+ public int getQuantity() {
+ return quantity;
+ }
+ /**
+ * @param quantity The quantity to set.
+ */
+ public void setQuantity(int quantity) {
+ this.quantity = quantity;
+ }
+ /**
+ * @return Returns the id.
+ */
+ public Id getId() {
+ return id;
+ }
+ /**
+ * @param id The id to set.
+ */
+ public void setId(Id id) {
+ this.id = id;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/Order.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/Order.hbm.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/Order.hbm.xml 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,66 @@
+<?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 package="mapping.cid">
+
+<!--
+
+ This mapping demonstrates
+
+ (1) composite keys and one-to-many associations on
+ composite keys
+
+ (2) use of insert="false" update="false" on an
+ association mapping, when the foreign key is
+ also part of the primary key
+
+ (3) use of a derived property which performs a
+ subselect against associated tables
+
+ (4) use of <synchronize/> to ensure that auto-flush
+ works correctly for an entity with a property
+ derived from other tables
+
+
+-->
+
+ <class name="Order" table="CustomerOrder">
+ <synchronize table="LineItem"/>
+ <synchronize table="Product"/>
+
+ <composite-id name="id"
+ class="Order$Id">
+ <key-property name="customerId" length="10"/>
+ <key-property name="orderNumber"/>
+ </composite-id>
+
+ <property name="orderDate"
+ type="calendar_date"
+ not-null="true"/>
+
+ <property name="total"
+ formula="( select sum(li.quantity*p.cost) from LineItem li, Product p where
li.productId = p.productId and li.customerId = customerId and li.orderNumber = orderNumber
)"/>
+
+ <many-to-one name="customer"
+ column="customerId"
+ insert="false"
+ update="false"
+ not-null="true"/>
+
+ <bag name="lineItems"
+ fetch="join"
+ lazy="false"
+ inverse="true"
+ cascade="save-update">
+ <key>
+ <column name="customerId"/>
+ <column name="orderNumber"/>
+ </key>
+ <one-to-many class="LineItem"/>
+ </bag>
+
+ </class>
+
+</hibernate-mapping>
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/Order.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/Order.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/Order.java 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,145 @@
+//$Id: Order.java 4806 2004-11-25 14:37:00Z steveebersole $
+package mapping.cid;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collection;
+
+/**
+ * @author Gavin King
+ */
+public class Order {
+ public static class Id implements Serializable {
+ private String customerId;
+ private int orderNumber;
+
+ public Id(String customerId, int orderNumber) {
+ this.customerId = customerId;
+ this.orderNumber = orderNumber;
+ }
+ public Id() {}
+
+ /**
+ * @return Returns the customerId.
+ */
+ public String getCustomerId() {
+ return customerId;
+ }
+ /**
+ * @param customerId The customerId to set.
+ */
+ public void setCustomerId(String customerId) {
+ this.customerId = customerId;
+ }
+ /**
+ * @return Returns the orderNumber.
+ */
+ public int getOrderNumber() {
+ return orderNumber;
+ }
+ /**
+ * @param orderNumber The orderNumber to set.
+ */
+ public void setOrderNumber(int orderNumber) {
+ this.orderNumber = orderNumber;
+ }
+ public int hashCode() {
+ return customerId.hashCode() + orderNumber;
+ }
+ public boolean equals(Object other) {
+ if (other instanceof Id) {
+ Id that = (Id) other;
+ return that.customerId.equals(this.customerId) &&
+ that.orderNumber == this.orderNumber;
+ }
+ else {
+ return false;
+ }
+ }
+ }
+
+ private Id id = new Id();
+ private Calendar orderDate;
+ private Customer customer;
+ private Collection lineItems = new ArrayList();
+ private BigDecimal total;
+
+ public Order(Customer customer) {
+ this.customer = customer;
+ this.id.customerId = customer.getCustomerId();
+ this.id.orderNumber = customer.getOrders().size();
+ customer.getOrders().add(this);
+ }
+
+ public Order() {}
+
+ /**
+ * @return Returns the customer.
+ */
+ public Customer getCustomer() {
+ return customer;
+ }
+ /**
+ * @param customer The customer to set.
+ */
+ public void setCustomer(Customer customer) {
+ this.customer = customer;
+ }
+ /**
+ * @return Returns the lineItems.
+ */
+ public Collection getLineItems() {
+ return lineItems;
+ }
+ /**
+ * @param lineItems The lineItems to set.
+ */
+ public void setLineItems(Collection lineItems) {
+ this.lineItems = lineItems;
+ }
+ /**
+ * @return Returns the orderDate.
+ */
+ public Calendar getOrderDate() {
+ return orderDate;
+ }
+ /**
+ * @param orderDate The orderDate to set.
+ */
+ public void setOrderDate(Calendar orderDate) {
+ this.orderDate = orderDate;
+ }
+ /**
+ * @return Returns the total.
+ */
+ public BigDecimal getTotal() {
+ return total;
+ }
+ /**
+ * @param total The total to set.
+ */
+ public void setTotal(BigDecimal total) {
+ this.total = total;
+ }
+ /**
+ * @return Returns the id.
+ */
+ public Id getId() {
+ return id;
+ }
+ /**
+ * @param id The id to set.
+ */
+ public void setId(Id id) {
+ this.id = id;
+ }
+
+ public LineItem generateLineItem( Product product, int quantity ) {
+ LineItem li = new LineItem( this, product );
+ li.setQuantity( quantity );
+ lineItems.add( li );
+ return li;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/Product.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/Product.hbm.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/Product.hbm.xml 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,40 @@
+<?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 package="mapping.cid">
+
+<!--
+
+ This mapping demonstrates
+
+ (1) use of a derived property which performs a
+ subselect against an associated table
+
+ (2) use of <synchronize/> to ensure that auto-flush
+ works correctly for an entity with a property
+ derived from another table
+
+
+-->
+
+ <class name="Product">
+ <synchronize table="LineItem"/>
+
+ <id name="productId"
+ length="10">
+ <generator class="assigned"/>
+ </id>
+
+ <property name="description"
+ not-null="true"
+ length="200"/>
+ <property name="price" length="3"
column="cost"/>
+ <property name="numberAvailable"/>
+
+ <property name="numberOrdered"
+ formula="( select sum(li.quantity) from LineItem li where li.productId =
productId )"/>
+ </class>
+
+</hibernate-mapping>
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/Product.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/Product.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cid/Product.java 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,75 @@
+//$Id: Product.java 4806 2004-11-25 14:37:00Z steveebersole $
+package mapping.cid;
+
+import java.math.BigDecimal;
+
+/**
+ * @author Gavin King
+ */
+public class Product {
+ private String productId;
+ private String description;
+ private BigDecimal price;
+ private int numberAvailable;
+ private int numberOrdered;
+ /**
+ * @return Returns the description.
+ */
+ public String getDescription() {
+ return description;
+ }
+ /**
+ * @param description The description to set.
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ }
+ /**
+ * @return Returns the numberAvailable.
+ */
+ public int getNumberAvailable() {
+ return numberAvailable;
+ }
+ /**
+ * @param numberAvailable The numberAvailable to set.
+ */
+ public void setNumberAvailable(int numberAvailable) {
+ this.numberAvailable = numberAvailable;
+ }
+ /**
+ * @return Returns the numberOrdered.
+ */
+ public int getNumberOrdered() {
+ return numberOrdered;
+ }
+ /**
+ * @param numberOrdered The numberOrdered to set.
+ */
+ public void setNumberOrdered(int numberOrdered) {
+ this.numberOrdered = numberOrdered;
+ }
+ /**
+ * @return Returns the productId.
+ */
+ public String getProductId() {
+ return productId;
+ }
+ /**
+ * @param productId The productId to set.
+ */
+ public void setProductId(String productId) {
+ this.productId = productId;
+ }
+ /**
+ * @return Returns the price.
+ */
+ public BigDecimal getPrice() {
+ return price;
+ }
+ /**
+ * @param price The price to set.
+ */
+ public void setPrice(BigDecimal price) {
+ this.price = price;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/bag/BagOwner.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/bag/BagOwner.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/bag/BagOwner.java 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,46 @@
+package mapping.collection.bag;
+
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class BagOwner {
+ private String name;
+ private BagOwner parent;
+ private List children = new ArrayList();
+
+ public BagOwner() {
+ }
+
+ public BagOwner(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public BagOwner getParent() {
+ return parent;
+ }
+
+ public void setParent(BagOwner parent) {
+ this.parent = parent;
+ }
+
+ public List getChildren() {
+ return children;
+ }
+
+ public void setChildren(List children) {
+ this.children = children;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/bag/Mappings.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/bag/Mappings.hbm.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/bag/Mappings.hbm.xml 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,20 @@
+<?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 package="mapping.collection.bag">
+
+ <class name="BagOwner">
+ <id name="name" column="NAME" type="string" />
+
+ <many-to-one name="parent" class="BagOwner"
cascade="none" />
+
+ <bag name="children" inverse="true"
cascade="all">
+ <key column="PARENT" />
+ <one-to-many class="BagOwner" />
+ </bag>
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/idbag/IdbagOwner.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/idbag/IdbagOwner.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/idbag/IdbagOwner.java 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,37 @@
+package mapping.collection.idbag;
+
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class IdbagOwner {
+ private String name;
+ private List children = new ArrayList();
+
+ public IdbagOwner() {
+ }
+
+ public IdbagOwner(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public List getChildren() {
+ return children;
+ }
+
+ public void setChildren(List children) {
+ this.children = children;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/idbag/Mappings.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/idbag/Mappings.hbm.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/idbag/Mappings.hbm.xml 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,21 @@
+<?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 package="mapping.collection.idbag">
+
+ <class name="IdbagOwner">
+ <id name="name" column="NAME" type="string" />
+
+ <idbag name="children" cascade="all"
table="idbag_owner_children">
+ <collection-id column="CHILD" type="long">
+ <generator class="increment"/>
+ </collection-id>
+ <key column="PARENT_FK" />
+ <many-to-many column="CHILD_FK" class="IdbagOwner"
/>
+ </idbag>
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/list/ListOwner.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/list/ListOwner.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/list/ListOwner.java 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,46 @@
+package mapping.collection.list;
+
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class ListOwner {
+ private String name;
+ private ListOwner parent;
+ private List children = new ArrayList();
+
+ public ListOwner() {
+ }
+
+ public ListOwner(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public ListOwner getParent() {
+ return parent;
+ }
+
+ public void setParent(ListOwner parent) {
+ this.parent = parent;
+ }
+
+ public List getChildren() {
+ return children;
+ }
+
+ public void setChildren(List children) {
+ this.children = children;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/list/Mappings.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/list/Mappings.hbm.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/list/Mappings.hbm.xml 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,21 @@
+<?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 package="mapping.collection.list">
+
+ <class name="ListOwner">
+ <id name="name" column="NAME" type="string" />
+
+ <many-to-one name="parent" class="ListOwner"
cascade="none" />
+
+ <list name="children" inverse="true"
cascade="all">
+ <key column="PARENT" />
+ <list-index column="LIST_INDEX"/>
+ <one-to-many class="ListOwner" />
+ </list>
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/map/Child.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/map/Child.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/map/Child.java 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,34 @@
+package mapping.collection.map;
+
+/**
+ * todo: describe Child
+ *
+ * @author Steve Ebersole
+ */
+public class Child {
+ private String name;
+ private Parent parent;
+
+ public Child() {
+ }
+
+ public Child(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Parent getParent() {
+ return parent;
+ }
+
+ public void setParent(Parent parent) {
+ this.parent = parent;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/map/Mappings.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/map/Mappings.hbm.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/map/Mappings.hbm.xml 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,24 @@
+<?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 package="mapping.collection.map">
+
+ <class name="Parent">
+ <id name="name" column="NAME" type="string" />
+
+ <map name="children" inverse="true"
cascade="all">
+ <key column="PARENT" />
+ <map-key type="string" />
+ <one-to-many class="Child" />
+ </map>
+ </class>
+
+ <class name="Child">
+ <id name="name" column="NAME"
type="string"/>
+ <many-to-one name="parent" class="Parent"
cascade="none" />
+ </class>
+
+</hibernate-mapping>
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/map/Parent.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/map/Parent.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/map/Parent.java 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,48 @@
+package mapping.collection.map;
+
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * todo: describe Parent
+ *
+ * @author Steve Ebersole
+ */
+public class Parent {
+ private String name;
+ private Map children = new HashMap();
+
+ public Parent() {
+ }
+
+ public Parent(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Map getChildren() {
+ return children;
+ }
+
+ public void setChildren(Map children) {
+ this.children = children;
+ }
+
+ public Child addChild(String name) {
+ Child child = new Child( name );
+ addChild( child );
+ return child;
+ }
+
+ public void addChild(Child child) {
+ child.setParent( this );
+ getChildren().put( child.getName(), child );
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/original/Email.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/original/Email.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/original/Email.java 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,27 @@
+//$Id: Email.java 5686 2005-02-12 07:27:32Z steveebersole $
+package mapping.collection.original;
+
+/**
+ * @author Gavin King
+ */
+public class Email {
+ private String address;
+ Email() {}
+ public String getAddress() {
+ return address;
+ }
+ public void setAddress(String type) {
+ this.address = type;
+ }
+ public Email(String type) {
+ this.address = type;
+ }
+ public boolean equals(Object that) {
+ if ( !(that instanceof Email) ) return false;
+ Email p = (Email) that;
+ return this.address.equals(p.address);
+ }
+ public int hashCode() {
+ return address.hashCode();
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/original/Permission.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/original/Permission.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/original/Permission.java 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,27 @@
+//$Id: Permission.java 5686 2005-02-12 07:27:32Z steveebersole $
+package mapping.collection.original;
+
+/**
+ * @author Gavin King
+ */
+public class Permission {
+ private String type;
+ Permission() {}
+ public String getType() {
+ return type;
+ }
+ public void setType(String type) {
+ this.type = type;
+ }
+ public Permission(String type) {
+ this.type = type;
+ }
+ public boolean equals(Object that) {
+ if ( !(that instanceof Permission) ) return false;
+ Permission p = (Permission) that;
+ return this.type.equals(p.type);
+ }
+ public int hashCode() {
+ return type.hashCode();
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/original/User.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/original/User.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/original/User.java 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,55 @@
+//$Id: User.java 7628 2005-07-24 06:55:01Z oneovthafew $
+package mapping.collection.original;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author Gavin King
+ */
+public class User {
+ private String userName;
+ private List permissions = new ArrayList();
+ private List emailAddresses = new ArrayList();
+ private Map sessionData = new HashMap();
+ private Set sessionAttributeNames = new HashSet();
+
+ User() {}
+ public User(String name) {
+ userName = name;
+ }
+ public List getPermissions() {
+ return permissions;
+ }
+ public void setPermissions(List permissions) {
+ this.permissions = permissions;
+ }
+ public String getUserName() {
+ return userName;
+ }
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+ public List getEmailAddresses() {
+ return emailAddresses;
+ }
+ public void setEmailAddresses(List emailAddresses) {
+ this.emailAddresses = emailAddresses;
+ }
+ public Map getSessionData() {
+ return sessionData;
+ }
+ public void setSessionData(Map sessionData) {
+ this.sessionData = sessionData;
+ }
+ public Set getSessionAttributeNames() {
+ return sessionAttributeNames;
+ }
+ public void setSessionAttributeNames(Set sessionAttributeNames) {
+ this.sessionAttributeNames = sessionAttributeNames;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/original/UserPermissions.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/original/UserPermissions.hbm.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/original/UserPermissions.hbm.xml 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,53 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<!--
+
+ This mapping demonstrates how to use a composite
+ element mapping to model a parent/child association.
+
+-->
+
+<hibernate-mapping package="mapping.collection.original">
+
+ <import class="Permission"/>
+
+ <class name="User" table="`Users`">
+ <id name="userName"/>
+ <list name="permissions" lazy="extra">
+ <key column="userName"/>
+ <list-index column="displayOrder" base="1"/>
+ <composite-element class="Permission">
+ <property name="type" column="permissionType"/>
+ </composite-element>
+ </list>
+ <list name="emailAddresses" fetch="join">
+ <key column="userName"/>
+ <list-index column="displayOrder" base="1"/>
+ <composite-element class="Email">
+ <property name="address"/>
+ </composite-element>
+ </list>
+ <map name="sessionData"
+ order-by="lower(`attributeName`) asc"
+ lazy="extra">
+ <key column="userName"/>
+ <map-key column="`attributeName`"
+ type="string"/>
+ <element column="`attributeValue`"
+ type="serializable"
+ not-null="true"/>
+ </map>
+ <set name="sessionAttributeNames"
+ lazy="extra"
+ inverse="true">
+ <key column="userName"/>
+ <element column="`attributeName`"
+ type="string"/>
+ </set>
+ </class>
+
+
+</hibernate-mapping>
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/set/Child.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/set/Child.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/set/Child.java 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,34 @@
+package mapping.collection.set;
+
+/**
+ * todo: describe Child
+ *
+ * @author Steve Ebersole
+ */
+public class Child {
+ private String name;
+ private Parent parent;
+
+ public Child() {
+ }
+
+ public Child(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Parent getParent() {
+ return parent;
+ }
+
+ public void setParent(Parent parent) {
+ this.parent = parent;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/set/Mappings.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/set/Mappings.hbm.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/set/Mappings.hbm.xml 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,23 @@
+<?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 package="mapping.collection.set">
+
+ <class name="Parent">
+ <id name="name" column="NAME" type="string" />
+
+ <set name="children" inverse="true"
cascade="all">
+ <key column="PARENT" />
+ <one-to-many class="Child" />
+ </set>
+ </class>
+
+ <class name="Child">
+ <id name="name" column="NAME"
type="string"/>
+ <many-to-one name="parent" class="Parent"
cascade="none" />
+ </class>
+
+</hibernate-mapping>
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/set/Parent.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/set/Parent.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/collection/set/Parent.java 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,37 @@
+package mapping.collection.set;
+
+import java.util.Set;
+import java.util.HashSet;
+
+/**
+ * todo: describe Parent
+ *
+ * @author Steve Ebersole
+ */
+public class Parent {
+ private String name;
+ private Set children = new HashSet();
+
+ public Parent() {
+ }
+
+ public Parent(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Set getChildren() {
+ return children;
+ }
+
+ public void setChildren(Set children) {
+ this.children = children;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/basic/Employee.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/basic/Employee.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/basic/Employee.java 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,38 @@
+package mapping.component.basic;
+
+import java.util.Date;
+
+/**
+ * todo: describe Employee
+ *
+ * @author Steve Ebersole
+ */
+public class Employee {
+ private Long id;
+ private Person person;
+ private Date hireDate;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public Person getPerson() {
+ return person;
+ }
+
+ public void setPerson(Person person) {
+ this.person = person;
+ }
+
+ public Date getHireDate() {
+ return hireDate;
+ }
+
+ public void setHireDate(Date hireDate) {
+ this.hireDate = hireDate;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/basic/Person.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/basic/Person.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/basic/Person.java 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,63 @@
+//$Id: Person.java 11346 2007-03-26 17:24:58Z steve.ebersole(a)jboss.com $
+package mapping.component.basic;
+
+import java.util.Date;
+
+/**
+ * @author Gavin King
+ */
+public class Person {
+ private String name;
+ private Date dob;
+ private String address;
+ private String currentAddress;
+ private String previousAddress;
+ private int yob;
+ Person() {}
+ public Person(String name, Date dob, String address) {
+ this.name = name;
+ this.dob = dob;
+ this.address = address;
+ this.currentAddress = address;
+ }
+ public int getYob() {
+ return yob;
+ }
+ public void setYob(int age) {
+ this.yob = age;
+ }
+ public String getAddress() {
+ return address;
+ }
+ public void setAddress(String address) {
+ this.address = address;
+ }
+ public Date getDob() {
+ return dob;
+ }
+ public void setDob(Date dob) {
+ this.dob = dob;
+ }
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+ public String getPreviousAddress() {
+ return previousAddress;
+ }
+ public void setPreviousAddress(String previousAddress) {
+ this.previousAddress = previousAddress;
+ }
+ public void changeAddress(String add) {
+ setPreviousAddress( getAddress() );
+ setAddress(add);
+ }
+ public String getCurrentAddress() {
+ return currentAddress;
+ }
+ public void setCurrentAddress(String currentAddress) {
+ this.currentAddress = currentAddress;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/basic/User.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/basic/User.hbm.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/basic/User.hbm.xml 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,42 @@
+<?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 package="mapping.component.basic">
+
+ <class name="User" table="T_USER">
+ <id name="userName"/>
+ <timestamp name="lastModified"/>
+ <property name="password" not-null="true"
optimistic-lock="false"/>
+ <component name="person">
+ <property name="name" update="false"
not-null="true"/>
+ <property name="dob" update="false"
not-null="true"/>
+ <property name="address"/>
+ <property name="previousAddress" insert="false"/>
+ <property name="yob" formula="year(dob)"/>
+ <property name="currentAddress"
+ column="address"
+ insert="false"
+ update="false"/>
+ </component>
+ </class>
+
+ <class name="Employee" table="T_EMP">
+ <id name="id" type="long" column="ID">
+ <generator class="increment"/>
+ </id>
+ <property name="hireDate" type="date"
column="HIRE_DATE"/>
+ <component name="person">
+ <property name="name" update="false"
not-null="true"/>
+ <property name="dob" update="false"
not-null="true"/>
+ </component>
+ </class>
+
+ <query name="userNameIn"><![CDATA[from User where person.name in
(:nameList) or userName in (:nameList)]]></query>
+
+</hibernate-mapping>
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/basic/User.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/basic/User.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/basic/User.java 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,44 @@
+//$Id: User.java 11346 2007-03-26 17:24:58Z steve.ebersole(a)jboss.com $
+package mapping.component.basic;
+
+import java.util.Date;
+
+/**
+ * @author Gavin King
+ */
+public class User {
+ private String userName;
+ private String password;
+ private Person person;
+ private Date lastModified;
+ User() {}
+ public User(String id, String pw, Person person) {
+ this.userName = id;
+ this.password = pw;
+ this.person = person;
+ }
+ public Date getLastModified() {
+ return lastModified;
+ }
+ public void setLastModified(Date lastModified) {
+ this.lastModified = lastModified;
+ }
+ public String getPassword() {
+ return password;
+ }
+ public void setPassword(String password) {
+ this.password = password;
+ }
+ public Person getPerson() {
+ return person;
+ }
+ public void setPerson(Person person) {
+ this.person = person;
+ }
+ public String getUserName() {
+ return userName;
+ }
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/collection/Definition.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/collection/Definition.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/collection/Definition.java 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,30 @@
+package mapping.component.cascading.collection;
+
+import java.util.Set;
+import java.util.HashSet;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class Definition {
+ private Long id;
+ private Set values = new HashSet();
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public Set getValues() {
+ return values;
+ }
+
+ public void setValues(Set values) {
+ this.values = values;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/collection/LocalizedStrings.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/collection/LocalizedStrings.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/collection/LocalizedStrings.java 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,26 @@
+package mapping.component.cascading.collection;
+
+import java.util.Locale;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class LocalizedStrings {
+ private Map strings = new HashMap();
+
+ public void addString(Locale locale, String value) {
+ strings.put( locale, value );
+ }
+
+ public String getString(Locale locale) {
+ return ( String ) strings.get( locale );
+ }
+
+ public Map getStringsCopy() {
+ return java.util.Collections.unmodifiableMap( strings );
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/collection/Mappings.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/collection/Mappings.hbm.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/collection/Mappings.hbm.xml 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="mapping.component.cascading.collection">
+
+ <class name="Definition" >
+ <id name="id" type="long" column="ID">
+ <generator class="increment"/>
+ </id>
+ <set name="values" cascade="all-delete-orphan,merge"
lazy="false" inverse="true">
+ <key column="DEF_ID" />
+ <one-to-many class="Value"/>
+ </set>
+ </class>
+
+ <class name="Value" >
+ <id name="id" type="long" column="ID">
+ <generator class="increment"/>
+ </id>
+
+ <many-to-one name="definition" class="Definition"
column="DEF_ID"/>
+
+ <component name="localizedStrings"
class="LocalizedStrings">
+ <map name="strings" access="field"
cascade="persist,merge" lazy="false">
+ <key column="VAL_ID" />
+ <map-key type="locale" column="LOC" />
+ <element type="string" column="STR_VAL" />
+ </map>
+ </component>
+
+ </class>
+
+</hibernate-mapping>
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/collection/Value.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/collection/Value.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/collection/Value.java 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,45 @@
+package mapping.component.cascading.collection;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class Value {
+ private Long id;
+ private Definition definition;
+ private LocalizedStrings localizedStrings = new LocalizedStrings();
+
+ private Value() {
+ }
+
+ public Value(Definition definition) {
+ this();
+ this.definition = definition;
+ definition.getValues().add( this );
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public Definition getDefinition() {
+ return definition;
+ }
+
+ public void setDefinition(Definition definition) {
+ this.definition = definition;
+ }
+
+ public LocalizedStrings getLocalizedStrings() {
+ return localizedStrings;
+ }
+
+ public void setLocalizedStrings(LocalizedStrings localizedStrings) {
+ this.localizedStrings = localizedStrings;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/toone/Address.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/toone/Address.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/toone/Address.java 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,63 @@
+package mapping.component.cascading.toone;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class Address {
+ private Long id;
+ private String street1;
+ private String street2;
+ private String city;
+ private String state;
+ private String zipCode;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getStreet1() {
+ return street1;
+ }
+
+ public void setStreet1(String street1) {
+ this.street1 = street1;
+ }
+
+ public String getStreet2() {
+ return street2;
+ }
+
+ public void setStreet2(String street2) {
+ this.street2 = street2;
+ }
+
+ public String getCity() {
+ return city;
+ }
+
+ public void setCity(String city) {
+ this.city = city;
+ }
+
+ public String getState() {
+ return state;
+ }
+
+ public void setState(String state) {
+ this.state = state;
+ }
+
+ public String getZipCode() {
+ return zipCode;
+ }
+
+ public void setZipCode(String zipCode) {
+ this.zipCode = zipCode;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/toone/Document.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/toone/Document.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/toone/Document.java 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,36 @@
+package mapping.component.cascading.toone;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class Document {
+ private Long id;
+ private String location;
+ private User owner;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getLocation() {
+ return location;
+ }
+
+ public void setLocation(String location) {
+ this.location = location;
+ }
+
+ public User getOwner() {
+ return owner;
+ }
+
+ public void setOwner(User owner) {
+ this.owner = owner;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/toone/Mappings.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/toone/Mappings.hbm.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/toone/Mappings.hbm.xml 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="mapping.component.cascading.toone">
+
+ <class name="Document" table="COMP_CASC_TO1_DOC">
+ <id name="id" type="long" column="ID">
+ <generator class="increment"/>
+ </id>
+ <many-to-one name="owner" class="User"
cascade="persist,merge,delete"/>
+ </class>
+
+ <class name="User" table="COMP_CASC_TO1_USER">
+ <id name="id" type="long" column="ID">
+ <generator class="increment"/>
+ </id>
+ <component name="personalInfo" class="PersonalInfo">
+ <many-to-one name="homeAddress" class="Address"
cascade="persist,merge,delete"/>
+ </component>
+ </class>
+
+ <class name="Address" table="COMP_CASC_TO1_ADDR">
+ <id name="id" type="long" column="ID">
+ <generator class="increment"/>
+ </id>
+ <property name="street1" type="string"
column="STREET1" />
+ <property name="street2" type="string"
column="STREET2" />
+ <property name="city" type="string"
column="CITY" />
+ <property name="state" type="string"
column="STATE" />
+ <property name="zipCode" type="string"
column="ZIP_CODE" />
+ </class>
+</hibernate-mapping>
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/toone/PersonalInfo.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/toone/PersonalInfo.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/toone/PersonalInfo.java 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,25 @@
+package mapping.component.cascading.toone;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class PersonalInfo {
+ private Address homeAddress = new Address();
+
+ public PersonalInfo() {
+ }
+
+ public PersonalInfo(Address homeAddress) {
+ this.homeAddress = homeAddress;
+ }
+
+ public Address getHomeAddress() {
+ return homeAddress;
+ }
+
+ public void setHomeAddress(Address homeAddress) {
+ this.homeAddress = homeAddress;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/toone/User.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/toone/User.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/component/cascading/toone/User.java 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,27 @@
+package mapping.component.cascading.toone;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class User {
+ private Long id;
+ private PersonalInfo personalInfo;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public PersonalInfo getPersonalInfo() {
+ return personalInfo;
+ }
+
+ public void setPersonalInfo(PersonalInfo personalInfo) {
+ this.personalInfo = personalInfo;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/compositeelement/Child.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/compositeelement/Child.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/compositeelement/Child.java 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,60 @@
+//$Id: Child.java 6978 2005-06-01 03:29:27Z oneovthafew $
+package mapping.compositeelement;
+
+/**
+ * @author gavin
+ */
+public class Child {
+ private String name;
+ private String bio;
+ private Parent parent;
+ private int bioLength;
+ Child() {}
+ public Child(String name) {
+ this.name = name;
+ }
+ /**
+ * @return Returns the name.
+ */
+ public String getName() {
+ return name;
+ }
+ /**
+ * @param name The name to set.
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+ /**
+ * @return Returns the parent.
+ */
+ public Parent getParent() {
+ return parent;
+ }
+ /**
+ * @param parent The parent to set.
+ */
+ public void setParent(Parent parent) {
+ this.parent = parent;
+ }
+ public String getBio() {
+ return bio;
+ }
+ public void setBio(String bio) {
+ this.bio = bio;
+ }
+ public int hashCode() {
+ return name.hashCode();
+ }
+ public boolean equals(Object other) {
+ Child c = (Child) other;
+ return c.parent.getId().equals(parent.getId())
+ && c.name.equals(name);
+ }
+ public int getBioLength() {
+ return bioLength;
+ }
+ public void setBioLength(Integer bioLength) {
+ this.bioLength = bioLength==null ? 0 : bioLength.intValue();
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/compositeelement/Parent.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/compositeelement/Parent.hbm.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/compositeelement/Parent.hbm.xml 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,36 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<!--
+
+ This mapping demonstrates how to use a composite
+ element mapping to model a parent/child association.
+
+-->
+
+<hibernate-mapping
+ package="mapping.compositeelement">
+
+ <import class="Child"/>
+
+ <class name="Parent">
+ <id name="id"
+ column="parent_id">
+ <generator class="increment"/>
+ </id>
+ <property name="name"/>
+ <set name="children" table="ParentChild">
+ <key column="parent_id"/>
+ <composite-element class="Child">
+ <parent name="parent"/>
+ <property name="name" not-null="true"/>
+ <property name="bio"/>
+ <property name="bioLength" formula="length(bio)"/>
+ </composite-element>
+ </set>
+ </class>
+
+
+</hibernate-mapping>
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/compositeelement/Parent.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/compositeelement/Parent.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/compositeelement/Parent.java 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,54 @@
+//$Id: Parent.java 4478 2004-09-02 02:30:28Z oneovthafew $
+package mapping.compositeelement;
+
+import java.util.Collection;
+import java.util.HashSet;
+
+/**
+ * @author gavin
+ */
+public class Parent {
+ private Long id;
+ private String name;
+ private Collection children = new HashSet();
+ Parent() {}
+ public Parent(String name) {
+ this.name = name;
+ }
+ /**
+ * @return Returns the children.
+ */
+ public Collection getChildren() {
+ return children;
+ }
+ /**
+ * @param children The children to set.
+ */
+ public void setChildren(Collection children) {
+ this.children = children;
+ }
+ /**
+ * @return Returns the id.
+ */
+ public Long getId() {
+ return id;
+ }
+ /**
+ * @param id The id to set.
+ */
+ public void setId(Long id) {
+ this.id = id;
+ }
+ /**
+ * @return Returns the name.
+ */
+ public String getName() {
+ return name;
+ }
+ /**
+ * @param name The name to set.
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/connections/Other.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/connections/Other.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/connections/Other.java 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,32 @@
+package mapping.connections;
+
+/**
+ * @author Steve Ebersole
+ */
+public class Other {
+ private Long id;
+ private String name;
+
+ public Other() {
+ }
+
+ public Other(String name) {
+ this.name = name;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/connections/Silly.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/connections/Silly.hbm.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/connections/Silly.hbm.xml 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,23 @@
+<?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 package="mapping.connections">
+
+ <class name="Silly">
+ <id name="id" type="long">
+ <generator class="native"/>
+ </id>
+ <property name="name"/>
+ <many-to-one name="other" class="Other"
cascade="all"/>
+ </class>
+
+ <class name="Other">
+ <id name="id" type="long">
+ <generator class="native"/>
+ </id>
+ <property name="name"/>
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/connections/Silly.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/connections/Silly.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/connections/Silly.java 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,51 @@
+// $Id: Silly.java 9595 2006-03-10 18:14:21Z steve.ebersole(a)jboss.com $
+package mapping.connections;
+
+import java.io.Serializable;
+
+/**
+ * Implementation of Silly.
+ *
+ * @author Steve Ebersole
+ */
+public class Silly implements Serializable {
+ private Long id;
+ private String name;
+ private Other other;
+
+ public Silly() {
+ }
+
+ public Silly(String name) {
+ this.name = name;
+ }
+
+ public Silly(String name, Other other) {
+ this.name = name;
+ this.other = other;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Other getOther() {
+ return other;
+ }
+
+ public void setOther(Other other) {
+ this.other = other;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/criteria/Course.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/criteria/Course.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/criteria/Course.java 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,22 @@
+//$Id: Course.java 5686 2005-02-12 07:27:32Z steveebersole $
+package mapping.criteria;
+
+/**
+ * @author Gavin King
+ */
+public class Course {
+ private String courseCode;
+ private String description;
+ public String getCourseCode() {
+ return courseCode;
+ }
+ public void setCourseCode(String courseCode) {
+ this.courseCode = courseCode;
+ }
+ public String getDescription() {
+ return description;
+ }
+ public void setDescription(String description) {
+ this.description = description;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/criteria/Enrolment.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/criteria/Enrolment.hbm.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/criteria/Enrolment.hbm.xml 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,45 @@
+<?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 package="mapping.criteria">
+
+ <class name="Course">
+ <id name="courseCode">
+ <generator class="assigned"/>
+ </id>
+ <property name="description"/>
+ </class>
+
+ <class name="Student">
+ <id name="studentNumber">
+ <column name="studentId"/>
+ <generator class="assigned"/>
+ </id>
+ <property name="name" not-null="true"/>
+ <set name="enrolments" inverse="true"
cascade="delete">
+ <key column="studentId"/>
+ <one-to-many class="Enrolment"/>
+ </set>
+ <many-to-one name="preferredCourse"
column="preferredCourseCode"/>
+ </class>
+
+ <class name="Enrolment">
+ <composite-id>
+ <key-property name="studentNumber">
+ <column name="studentId"/>
+ </key-property>
+ <key-property name="courseCode"/>
+ </composite-id>
+ <many-to-one name="student" insert="false"
update="false">
+ <column name="studentId"/>
+ </many-to-one>
+ <many-to-one name="course" insert="false"
update="false">
+ <column name="courseCode"/>
+ </many-to-one>
+ <property name="semester" not-null="true"/>
+ <property name="year" not-null="true"/>
+ </class>
+
+</hibernate-mapping>
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/criteria/Enrolment.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/criteria/Enrolment.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/criteria/Enrolment.java 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,63 @@
+//$Id: Enrolment.java 6970 2005-05-31 20:24:41Z oneovthafew $
+package mapping.criteria;
+
+import java.io.Serializable;
+
+/**
+ * @author Gavin King
+ */
+public class Enrolment implements Serializable {
+ private Student student;
+ private Course course;
+ private long studentNumber;
+ private String courseCode;
+ private short year;
+ private short semester;
+ public String getCourseCode() {
+ return courseCode;
+ }
+ public void setCourseCode(String courseId) {
+ this.courseCode = courseId;
+ }
+ public long getStudentNumber() {
+ return studentNumber;
+ }
+ public void setStudentNumber(long studentId) {
+ this.studentNumber = studentId;
+ }
+ public Course getCourse() {
+ return course;
+ }
+ public void setCourse(Course course) {
+ this.course = course;
+ }
+ public Student getStudent() {
+ return student;
+ }
+ public void setStudent(Student student) {
+ this.student = student;
+ }
+ public short getSemester() {
+ return semester;
+ }
+ public void setSemester(short semester) {
+ this.semester = semester;
+ }
+ public short getYear() {
+ return year;
+ }
+ public void setYear(short year) {
+ this.year = year;
+ }
+
+ public boolean equals(Object other) {
+ if ( !(other instanceof Enrolment) ) return false;
+ Enrolment that = (Enrolment) other;
+ return studentNumber==that.studentNumber &&
+ courseCode.equals(that.courseCode);
+ }
+
+ public int hashCode() {
+ return courseCode.hashCode();
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/criteria/Student.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/criteria/Student.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/criteria/Student.java 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,47 @@
+//$Id: Student.java 9116 2006-01-23 21:21:01Z steveebersole $
+package mapping.criteria;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @author Gavin King
+ */
+public class Student {
+ private long studentNumber;
+ private String name;
+ private Course preferredCourse;
+ private Set enrolments = new HashSet();
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public long getStudentNumber() {
+ return studentNumber;
+ }
+
+ public void setStudentNumber(long studentNumber) {
+ this.studentNumber = studentNumber;
+ }
+
+ public Course getPreferredCourse() {
+ return preferredCourse;
+ }
+
+ public void setPreferredCourse(Course preferredCourse) {
+ this.preferredCourse = preferredCourse;
+ }
+
+ public Set getEnrolments() {
+ return enrolments;
+ }
+
+ public void setEnrolments(Set employments) {
+ this.enrolments = employments;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cuk/Account.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cuk/Account.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cuk/Account.java 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,50 @@
+//$Id: Account.java 4592 2004-09-26 00:39:43Z oneovthafew $
+package mapping.cuk;
+
+import java.io.Serializable;
+
+/**
+ * @author Gavin King
+ */
+public class Account implements Serializable {
+ private String accountId;
+ private Person user;
+ private char type;
+ /**
+ * @return Returns the user.
+ */
+ public Person getUser() {
+ return user;
+ }
+ /**
+ * @param user The user to set.
+ */
+ public void setUser(Person user) {
+ this.user = user;
+ }
+ /**
+ * @return Returns the accountId.
+ */
+ public String getAccountId() {
+ return accountId;
+ }
+ /**
+ * @param accountId The accountId to set.
+ */
+ public void setAccountId(String accountId) {
+ this.accountId = accountId;
+ }
+ /**
+ * @return Returns the type.
+ */
+ public char getType() {
+ return type;
+ }
+ /**
+ * @param type The type to set.
+ */
+ public void setType(char type) {
+ this.type = type;
+ }
+
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cuk/Address.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cuk/Address.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cuk/Address.java 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,75 @@
+//$Id: Address.java 4592 2004-09-26 00:39:43Z oneovthafew $
+package mapping.cuk;
+
+import java.io.Serializable;
+
+/**
+ * @author gavin
+ */
+public class Address implements Serializable {
+ private Long id;
+ private String address;
+ private String zip;
+ private String country;
+ private Person person;
+ /**
+ * @return Returns the id.
+ */
+ public Long getId() {
+ return id;
+ }
+ /**
+ * @param id The id to set.
+ */
+ public void setId(Long id) {
+ this.id = id;
+ }
+ /**
+ * @return Returns the person.
+ */
+ public Person getPerson() {
+ return person;
+ }
+ /**
+ * @param person The person to set.
+ */
+ public void setPerson(Person person) {
+ this.person = person;
+ }
+ /**
+ * @return Returns the address.
+ */
+ public String getAddress() {
+ return address;
+ }
+ /**
+ * @param address The address to set.
+ */
+ public void setAddress(String address) {
+ this.address = address;
+ }
+ /**
+ * @return Returns the country.
+ */
+ public String getCountry() {
+ return country;
+ }
+ /**
+ * @param country The country to set.
+ */
+ public void setCountry(String country) {
+ this.country = country;
+ }
+ /**
+ * @return Returns the zip.
+ */
+ public String getZip() {
+ return zip;
+ }
+ /**
+ * @param zip The zip to set.
+ */
+ public void setZip(String zip) {
+ this.zip = zip;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cuk/Person.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cuk/Person.hbm.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cuk/Person.hbm.xml 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,63 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<!--
+
+ Demonstrates the use of property-ref to map legacy data where
+ foreign keys reference something other than the primary key of
+ the associated entity. Here we show:
+
+ (1) A one-to-one foreign key association (prefer primary key
+ associations)
+
+ (2) A bidirectional one-to-many association on a key that is
+ comprised of several properties of the associated entity
+
+-->
+
+<hibernate-mapping package="mapping.cuk">
+
+ <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 property-ref="userIdAndDeleted">
+ <column name="userId"/>
+ <column name="userDeleted"/>
+ </key>
+ <one-to-many class="Account"/>
+ </set>
+ <properties name="userIdAndDeleted" update="false"
unique="true">
+ <property name="userId" length="8"/>
+ <property name="deleted"/>
+ </properties>
+
+ </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">
+ <id name="accountId" length="32">
+ <generator class="uuid.hex"/>
+ </id>
+ <many-to-one name="user" property-ref="userIdAndDeleted">
+ <column name="userId"/>
+ <column name="userDeleted"/>
+ </many-to-one>
+ <property name="type" not-null="true"/>
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cuk/Person.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cuk/Person.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cuk/Person.java 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,100 @@
+//$Id: Person.java 4592 2004-09-26 00:39:43Z oneovthafew $
+package mapping.cuk;
+
+import java.io.Serializable;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @author gavin
+ */
+public class Person implements Serializable {
+ private Long id;
+ private String name;
+ private Address address;
+ private String userId;
+ private boolean deleted;
+ private Set accounts = new HashSet();
+ /**
+ * @return Returns the userId.
+ */
+ public String getUserId() {
+ return userId;
+ }
+ /**
+ * @param userId The userId to set.
+ */
+ public void setUserId(String userId) {
+ this.userId = userId;
+ }
+ /**
+ * @return Returns the address.
+ */
+ public Address getAddress() {
+ return address;
+ }
+ /**
+ * @param address The address to set.
+ */
+ public void setAddress(Address address) {
+ this.address = address;
+ }
+ /**
+ * @return Returns the id.
+ */
+ public Long getId() {
+ return id;
+ }
+ /**
+ * @param id The id to set.
+ */
+ public void setId(Long id) {
+ this.id = id;
+ }
+ /**
+ * @return Returns the name.
+ */
+ public String getName() {
+ return name;
+ }
+ /**
+ * @param name The name to set.
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+ /**
+ * @return Returns the accounts.
+ */
+ public Set getAccounts() {
+ return accounts;
+ }
+ /**
+ * @param accounts The accounts to set.
+ */
+ public void setAccounts(Set accounts) {
+ this.accounts = accounts;
+ }
+
+ public boolean isDeleted() {
+ return deleted;
+ }
+
+ public void setDeleted(boolean deleted) {
+ this.deleted = deleted;
+ }
+
+ public boolean equals(Object other) {
+ if (other instanceof Person) {
+ Person that = (Person) other;
+ return that.isDeleted() == deleted && that.getUserId().equals(userId);
+ }
+ else {
+ return false;
+ }
+ }
+
+ public int hashCode() {
+ return userId.hashCode();
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cut/MonetoryAmount.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cut/MonetoryAmount.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cut/MonetoryAmount.java 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,37 @@
+//$Id: MonetoryAmount.java 6234 2005-03-29 03:07:30Z oneovthafew $
+package mapping.cut;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Currency;
+
+/**
+ * @author Gavin King
+ */
+public class MonetoryAmount implements Serializable {
+
+ private BigDecimal amount;
+ private Currency currency;
+
+ public MonetoryAmount(BigDecimal amount, Currency currency) {
+ this.amount = amount;
+ this.currency = currency;
+ }
+
+ public BigDecimal getAmount() {
+ return amount;
+ }
+
+ public void setAmount(BigDecimal amount) {
+ this.amount = amount;
+ }
+
+ public Currency getCurrency() {
+ return currency;
+ }
+
+ public void setCurrency(Currency currency) {
+ this.currency = currency;
+ }
+
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cut/MonetoryAmountUserType.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cut/MonetoryAmountUserType.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cut/MonetoryAmountUserType.java 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,104 @@
+//$Id: MonetoryAmountUserType.java 6235 2005-03-29 03:17:49Z oneovthafew $
+package mapping.cut;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Currency;
+
+import org.hibernate.Hibernate;
+import org.hibernate.HibernateException;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.type.Type;
+import org.hibernate.usertype.CompositeUserType;
+
+/**
+ * @author Gavin King
+ */
+public class MonetoryAmountUserType implements CompositeUserType {
+
+ public String[] getPropertyNames() {
+ return new String[] { "amount", "currency" };
+ }
+
+ public Type[] getPropertyTypes() {
+ return new Type[] { Hibernate.BIG_DECIMAL, Hibernate.CURRENCY };
+ }
+
+ public Object getPropertyValue(Object component, int property) throws HibernateException
{
+ MonetoryAmount ma = (MonetoryAmount) component;
+ return property==0 ? (Object) ma.getAmount() : (Object) ma.getCurrency();
+ }
+
+ public void setPropertyValue(Object component, int property, Object value)
+ throws HibernateException {
+ MonetoryAmount ma = (MonetoryAmount) component;
+ if ( property==0 ) {
+ ma.setAmount( (BigDecimal) value );
+ }
+ else {
+ ma.setCurrency( (Currency) value );
+ }
+ }
+
+ public Class returnedClass() {
+ return MonetoryAmount.class;
+ }
+
+ public boolean equals(Object x, Object y) throws HibernateException {
+ if (x==y) return true;
+ if (x==null || y==null) return false;
+ MonetoryAmount mx = (MonetoryAmount) x;
+ MonetoryAmount my = (MonetoryAmount) y;
+ return mx.getAmount().equals( my.getAmount() ) &&
+ mx.getCurrency().equals( my.getCurrency() );
+ }
+
+ public int hashCode(Object x) throws HibernateException {
+ return ( (MonetoryAmount) x ).getAmount().hashCode();
+ }
+
+ public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session,
Object owner)
+ throws HibernateException, SQLException {
+ BigDecimal amt = (BigDecimal) Hibernate.BIG_DECIMAL.nullSafeGet( rs, names[0] );
+ Currency cur = (Currency) Hibernate.CURRENCY.nullSafeGet( rs, names[1] );
+ if (amt==null) return null;
+ return new MonetoryAmount(amt, cur);
+ }
+
+ public void nullSafeSet(PreparedStatement st, Object value, int index,
+ SessionImplementor session) throws HibernateException, SQLException {
+ MonetoryAmount ma = (MonetoryAmount) value;
+ BigDecimal amt = ma == null ? null : ma.getAmount();
+ Currency cur = ma == null ? null : ma.getCurrency();
+ Hibernate.BIG_DECIMAL.nullSafeSet(st, amt, index);
+ Hibernate.CURRENCY.nullSafeSet(st, cur, index+1);
+ }
+
+ public Object deepCopy(Object value) throws HibernateException {
+ MonetoryAmount ma = (MonetoryAmount) value;
+ return new MonetoryAmount( ma.getAmount(), ma.getCurrency() );
+ }
+
+ public boolean isMutable() {
+ return true;
+ }
+
+ public Serializable disassemble(Object value, SessionImplementor session)
+ throws HibernateException {
+ return (Serializable) deepCopy(value);
+ }
+
+ public Object assemble(Serializable cached, SessionImplementor session, Object owner)
+ throws HibernateException {
+ return deepCopy(cached);
+ }
+
+ public Object replace(Object original, Object target, SessionImplementor session, Object
owner)
+ throws HibernateException {
+ return deepCopy(original); //TODO: improve
+ }
+
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cut/Transaction.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cut/Transaction.hbm.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cut/Transaction.hbm.xml 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<!--
+
+ Demonstrates the use of a CompositeUserType.
+
+-->
+
+<hibernate-mapping package="mapping.cut">
+
+ <class name="Transaction" table="Trnsctn">
+ <id name="id">
+ <generator class="native"/>
+ </id>
+ <property name="description" length="100"
not-null="true"/>
+ <property name="value" type="money">
+ <column name="amount" not-null="true"/>
+ <column name="currency" not-null="true"/>
+ </property>
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cut/Transaction.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cut/Transaction.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cut/Transaction.java 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,37 @@
+//$Id: Transaction.java 6234 2005-03-29 03:07:30Z oneovthafew $
+package mapping.cut;
+
+/**
+ * @author Gavin King
+ */
+public class Transaction {
+
+ private Long id;
+ private String description;
+ private MonetoryAmount value;
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public MonetoryAmount getValue() {
+ return value;
+ }
+
+ public void setValue(MonetoryAmount value) {
+ this.value = value;
+ }
+
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cut/types.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cut/types.hbm.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/cut/types.hbm.xml 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,8 @@
+<?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 package="mapping.cut">
+ <typedef name="money"
class="org.hibernate.test.cut.MonetoryAmountUserType"/>
+</hibernate-mapping>
\ No newline at end of file
Modified:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/declaration/id/composite/v1/KeyManyToOneClass.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/declaration/id/composite/v1/KeyManyToOneClass.hbm.xml 2007-07-10
14:46:27 UTC (rev 2367)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/declaration/id/composite/v1/KeyManyToOneClass.hbm.xml 2007-07-10
14:49:00 UTC (rev 2368)
@@ -4,6 +4,6 @@
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="mapping.declaration.id.composite.v1">
<class name="KeyManyToOneClass"
table="CompositeIdMappedClassTable">
- <id name="keyId" column="KeyID" type="integer"/>
+ <id name="keyId" column="KeyID" type="integer"/>
</class>
</hibernate-mapping>
\ No newline at end of file
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/deletetransient/Address.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/deletetransient/Address.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/deletetransient/Address.java 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,34 @@
+package mapping.deletetransient;
+
+/**
+ * todo: describe Address
+ *
+ * @author Steve Ebersole
+ */
+public class Address {
+ private Long id;
+ private String info;
+
+ public Address() {
+ }
+
+ public Address(String info) {
+ this.info = info;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getInfo() {
+ return info;
+ }
+
+ public void setInfo(String info) {
+ this.info = info;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/deletetransient/Person.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/deletetransient/Person.hbm.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/deletetransient/Person.hbm.xml 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,34 @@
+<?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 package="mapping.deletetransient">
+
+ <class name="Person" table="T_PERSON">
+ <id name="id" type="long">
+ <generator class="increment"/>
+ </id>
+ <property name="name" type="string"/>
+ <set name="addresses" lazy="true"
inverse="false" cascade="all">
+ <key column="PERSON_ID"/>
+ <one-to-many class="Address"/>
+ </set>
+ <bag name="friends" lazy="true" inverse="false"
cascade="all" table="T_FRIENDS">
+ <key column="FRIEND_ID_1"/>
+ <many-to-many class="Person"
column="FRIEND_ID_2"/>
+ </bag>
+ </class>
+
+ <class name="Address" table="T_ADDRESS">
+ <id name="id" type="long">
+ <generator class="increment"/>
+ </id>
+ <property name="info" type="string"/>
+ </class>
+
+</hibernate-mapping>
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/deletetransient/Person.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/deletetransient/Person.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/deletetransient/Person.java 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,57 @@
+package mapping.deletetransient;
+
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Collection;
+import java.util.ArrayList;
+
+/**
+ * todo: describe Person
+ *
+ * @author Steve Ebersole
+ */
+public class Person {
+ private Long id;
+ private String name;
+ private Set addresses = new HashSet();
+ private Collection friends = new ArrayList();
+
+ public Person() {
+ }
+
+ public Person(String name) {
+ this.name = name;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Set getAddresses() {
+ return addresses;
+ }
+
+ public void setAddresses(Set addresses) {
+ this.addresses = addresses;
+ }
+
+ public Collection getFriends() {
+ return friends;
+ }
+
+ public void setFriends(Collection friends) {
+ this.friends = friends;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/dialect/functional/cache/TestInterSystemsFunctionsClass.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/dialect/functional/cache/TestInterSystemsFunctionsClass.hbm.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/dialect/functional/cache/TestInterSystemsFunctionsClass.hbm.xml 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,18 @@
+<?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 package="mapping.dialect.functional.cache" >
+
+ <class name="TestInterSystemsFunctionsClass"
table="SQLUser.TestInterSystemsFunctionsClass">
+ <id type="long" column="id_">
+ <generator class="assigned"/>
+ </id>
+ <property name="date" column="date_"/>
+ <property name="date1" column="date1_"/>
+ <property name="date3" column="date3_"/>
+ <property name="dateText" column="dateText_"/>
+ </class>
+
+</hibernate-mapping>
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/dialect/functional/cache/TestInterSystemsFunctionsClass.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/dialect/functional/cache/TestInterSystemsFunctionsClass.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/dialect/functional/cache/TestInterSystemsFunctionsClass.java 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,51 @@
+package mapping.dialect.functional.cache;
+
+import java.util.Date;
+
+/**
+ * Entity for testing function support of InterSystems' CacheSQL...
+ *
+ * @author Jonathan Levinson
+ */
+public class TestInterSystemsFunctionsClass {
+ private java.util.Date date3;
+ private java.util.Date date1;
+ private java.util.Date date;
+ private String dateText;
+
+ public Date getDate() {
+ return date;
+ }
+
+ public void setDate(Date date) {
+ this.date = date;
+ }
+
+
+ public String getDateText() {
+ return dateText;
+ }
+
+ public void setDateText(String dateText) {
+ this.dateText = dateText;
+ }
+
+
+ public Date getDate1() {
+ return date1;
+ }
+
+ public void setDate1(Date date1) {
+ this.date1 = date1;
+ }
+
+
+ public Date getDate3() {
+ return date3;
+ }
+
+ public void setDate3(Date date3) {
+ this.date3 = date3;
+ }
+
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/discriminator/Address.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/discriminator/Address.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/discriminator/Address.java 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,11 @@
+//$Id: Address.java 4373 2004-08-18 09:18:34Z oneovthafew $
+package mapping.discriminator;
+
+/**
+ * @author Gavin King
+ */
+public class Address {
+ public String address;
+ public String zip;
+ public String country;
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/discriminator/Customer.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/discriminator/Customer.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/discriminator/Customer.java 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,35 @@
+//$Id: Customer.java 4373 2004-08-18 09:18:34Z oneovthafew $
+package mapping.discriminator;
+
+/**
+ * @author Gavin King
+ */
+public class Customer extends Person {
+ private Employee salesperson;
+ private String comments;
+
+ /**
+ * @return Returns the salesperson.
+ */
+ public Employee getSalesperson() {
+ return salesperson;
+ }
+ /**
+ * @param salesperson The salesperson to set.
+ */
+ public void setSalesperson(Employee salesperson) {
+ this.salesperson = salesperson;
+ }
+ /**
+ * @return Returns the comments.
+ */
+ public String getComments() {
+ return comments;
+ }
+ /**
+ * @param comments The comments to set.
+ */
+ public void setComments(String comments) {
+ this.comments = comments;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/discriminator/Employee.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/discriminator/Employee.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/discriminator/Employee.java 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,49 @@
+//$Id: Employee.java 4373 2004-08-18 09:18:34Z oneovthafew $
+package mapping.discriminator;
+
+import java.math.BigDecimal;
+
+/**
+ * @author Gavin King
+ */
+public class Employee extends Person {
+ private String title;
+ private BigDecimal salary;
+ private Employee manager;
+ /**
+ * @return Returns the title.
+ */
+ public String getTitle() {
+ return title;
+ }
+ /**
+ * @param title The title to set.
+ */
+ public void setTitle(String title) {
+ this.title = title;
+ }
+ /**
+ * @return Returns the manager.
+ */
+ public Employee getManager() {
+ return manager;
+ }
+ /**
+ * @param manager The manager to set.
+ */
+ public void setManager(Employee manager) {
+ this.manager = manager;
+ }
+ /**
+ * @return Returns the salary.
+ */
+ public BigDecimal getSalary() {
+ return salary;
+ }
+ /**
+ * @param salary The salary to set.
+ */
+ public void setSalary(BigDecimal salary) {
+ this.salary = salary;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/discriminator/Person.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/discriminator/Person.hbm.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/discriminator/Person.hbm.xml 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,64 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<!--
+
+ This mapping demonstrates content-based discrimination for the
+ table-per-hierarchy mapping strategy, using a formula
+ discriminator.
+
+-->
+
+<hibernate-mapping
+ package="mapping.discriminator"
+ default-access="field">
+
+ <class name="Person"
+ discriminator-value="P">
+
+ <id name="id"
+ column="person_id"
+ unsaved-value="0">
+ <generator class="native"/>
+ </id>
+
+
+ <discriminator
+ type="character"
+ formula="case when title is not null then 'E' when salesperson is not
null then 'C' else 'P' end"/>
+
+ <property name="name"
+ not-null="true"
+ length="80"/>
+
+ <property name="sex"
+ not-null="true"
+ update="false"/>
+
+ <component name="address">
+ <property name="address"/>
+ <property name="zip"/>
+ <property name="country"/>
+ </component>
+
+ <subclass name="Employee"
+ discriminator-value="E">
+ <property name="title"
+ length="20"/>
+ <property name="salary"
+ length="0"/>
+ <many-to-one name="manager"/>
+ </subclass>
+
+ <subclass name="Customer"
+ discriminator-value="C">
+ <property name="comments"/>
+ <many-to-one name="salesperson"/>
+ </subclass>
+
+ </class>
+
+
+</hibernate-mapping>
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/discriminator/Person.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/discriminator/Person.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/discriminator/Person.java 2007-07-10
14:49:00 UTC (rev 2368)
@@ -0,0 +1,70 @@
+//$Id: Person.java 4373 2004-08-18 09:18:34Z oneovthafew $
+package mapping.discriminator;
+
+
+/**
+ * @author Gavin King
+ */
+public class Person {
+ private long id;
+ private String name;
+ private char sex;
+ private Address address = new Address();
+ /**
+ * @return Returns the address.
+ */
+ public Address getAddress() {
+ return address;
+ }
+
+ public void setAddress(String string) {
+ this.address.address = string;
+ }
+
+ public void setZip(String string) {
+ this.address.zip = string;
+ }
+
+ public void setCountry(String string) {
+ this.address.country = string;
+ }
+
+
+ /**
+ * @return Returns the sex.
+ */
+ public char getSex() {
+ return sex;
+ }
+ /**
+ * @param sex The sex to set.
+ */
+ public void setSex(char sex) {
+ this.sex = sex;
+ }
+ /**
+ * @return Returns the id.
+ */
+ public long getId() {
+ return id;
+ }
+ /**
+ * @param id The id to set.
+ */
+ public void setId(long id) {
+ this.id = id;
+ }
+ /**
+ * @return Returns the identity.
+ */
+ public String getName() {
+ return name;
+ }
+ /**
+ * @param identity The identity to set.
+ */
+ public void setName(String identity) {
+ this.name = identity;
+ }
+
+}