Author: mdryakhlenkov
Date: 2007-07-26 09:44:25 -0400 (Thu, 26 Jul 2007)
New Revision: 2677
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/lob/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/lob/LobHolder.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/lob/LobMappings.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/lob/SerializableData.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/manytomany/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/manytomany/Group.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/manytomany/User.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/manytomany/UserGroup.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/manytomany/ordered/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/manytomany/ordered/Group.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/manytomany/ordered/User.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/manytomany/ordered/UserGroup.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/map/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/map/Group.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/map/SessionAttribute.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/map/User.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/map/UserGroup.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mapcompelem/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mapcompelem/Item.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mapcompelem/Part.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mapcompelem/Product.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mapcompelem/ProductPart.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mapelemformula/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mapelemformula/Group.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mapelemformula/User.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mapelemformula/UserGroup.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mappingexception/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mappingexception/InvalidMapping.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mappingexception/InvalidMapping.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mappingexception/User.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mappingexception/User.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mixed/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mixed/Document.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mixed/DocumentInterceptor.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mixed/Folder.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mixed/Item.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mixed/Item.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mixed/SecureDocument.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/naturalid/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/naturalid/User.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/naturalid/User.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/ondelete/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/ondelete/Address.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/ondelete/Employee.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/ondelete/Person.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/ondelete/Person.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/ondelete/Salesperson.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetomany/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetomany/Child.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetomany/Parent.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetomany/Parent.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetoone/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetoone/formula/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetoone/formula/Address.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetoone/formula/Person.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetoone/formula/Person.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetoone/joined/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetoone/joined/Address.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetoone/joined/Entity.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetoone/joined/Org.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetoone/joined/Person.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetoone/joined/Person.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetoone/link/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetoone/link/Customer.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetoone/link/Employee.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetoone/link/Person.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetoone/link/Person.java
Log:
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/lob/LobHolder.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/lob/LobHolder.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/lob/LobHolder.java 2007-07-26
13:44:25 UTC (rev 2677)
@@ -0,0 +1,90 @@
+package mapping.lob;
+
+import java.io.Serializable;
+import java.sql.Clob;
+import java.sql.Blob;
+
+/**
+ * An entity containing all kinds of good LOB-type data...
+ * <p/>
+ * {@link #serialData} is used to hold general serializable data which is
+ * mapped via the {@link org.hibernate.type.SerializableType}.
+ * <p/>
+ * {@link #materializedClob} is used to hold CLOB data that is materialized
+ * into a String immediately; it is mapped via the
+ * {@link org.hibernate.type.TextType}.
+ * <p/>
+ * {@link #clobLocator} is used to hold CLOB data that is materialized lazily
+ * via a JDBC CLOB locator; it is mapped via the
+ * {@link org.hibernate.type.ClobType}
+ * <p/>
+ * {@link #materializedBlob} is used to hold BLOB data that is materialized
+ * into a byte array immediately; it is mapped via the
+ * {@link org.hibernate.test.lob.MaterializedBlobType}.
+ * <p/>
+ * {@link #blobLocator} is used to hold BLOB data that is materialized lazily
+ * via a JDBC BLOB locator; it is mapped via the
+ * {@link org.hibernate.type.BlobType}
+ *
+ *
+ * @author Steve Ebersole
+ */
+public class LobHolder {
+ private Long id;
+
+ private Serializable serialData;
+
+ private String materializedClob;
+ private Clob clobLocator;
+
+ private byte[] materializedBlob;
+ private Blob blobLocator;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public Serializable getSerialData() {
+ return serialData;
+ }
+
+ public void setSerialData(Serializable serialData) {
+ this.serialData = serialData;
+ }
+
+ public String getMaterializedClob() {
+ return materializedClob;
+ }
+
+ public void setMaterializedClob(String materializedClob) {
+ this.materializedClob = materializedClob;
+ }
+
+ public Clob getClobLocator() {
+ return clobLocator;
+ }
+
+ public void setClobLocator(Clob clobLocator) {
+ this.clobLocator = clobLocator;
+ }
+
+ public byte[] getMaterializedBlob() {
+ return materializedBlob;
+ }
+
+ public void setMaterializedBlob(byte[] materializedBlob) {
+ this.materializedBlob = materializedBlob;
+ }
+
+ public Blob getBlobLocator() {
+ return blobLocator;
+ }
+
+ public void setBlobLocator(Blob blobLocator) {
+ this.blobLocator = blobLocator;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/lob/LobMappings.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/lob/LobMappings.hbm.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/lob/LobMappings.hbm.xml 2007-07-26
13:44:25 UTC (rev 2677)
@@ -0,0 +1,22 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="mapping.lob">
+
+ <class name="LobHolder" table="LOB_ENTITY">
+ <id name="id" type="long" column="ID">
+ <generator class="increment"/>
+ </id>
+
+ <property name="serialData" column="SER_DATA"
type="serializable"/>
+
+ <property name="materializedClob" column="MAT_CLOB_DATA"
type="text" length="15000"/>
+ <property name="clobLocator" column="CLOB_DATA"
type="clob" length="15000" />
+
+ <property name="materializedBlob" column="MAT_BLOB_DATA"
type="org.hibernate.test.lob.MaterializedBlobType"
length="15000"/>
+ <property name="blobLocator" column="BLOB_DATA"
type="blob" length="15000" />
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/lob/SerializableData.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/lob/SerializableData.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/lob/SerializableData.java 2007-07-26
13:44:25 UTC (rev 2677)
@@ -0,0 +1,29 @@
+// $Id: SerializableData.java 4704 2004-11-04 21:59:22Z steveebersole $
+package mapping.lob;
+
+import java.io.Serializable;
+
+/**
+ * Implementation of SerializableData.
+ *
+ * @author Steve
+ */
+public class SerializableData implements Serializable
+{
+ private String payload;
+
+ public SerializableData(String payload)
+ {
+ this.payload = payload;
+ }
+
+ public String getPayload()
+ {
+ return payload;
+ }
+
+ public void setPayload(String payload)
+ {
+ this.payload = payload;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/manytomany/Group.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/manytomany/Group.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/manytomany/Group.java 2007-07-26
13:44:25 UTC (rev 2677)
@@ -0,0 +1,56 @@
+//$Id: Group.java 7085 2005-06-08 17:59:47Z oneovthafew $
+package mapping.manytomany;
+
+import java.io.Serializable;
+import java.util.HashSet;
+import java.util.Set;
+
+public class Group implements Serializable {
+
+ private String org;
+ private String name;
+ private String description;
+
+ private Set users = new HashSet();
+
+ public Group(String name, String org) {
+
this.org = org;
+ this.name = name;
+ }
+
+ public Group() {
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getOrg() {
+ return org;
+ }
+
+ public void setOrg(String org) {
+
this.org = org;
+ }
+
+ public Set getUsers() {
+ return users;
+ }
+
+ public void setUsers(Set users) {
+ this.users = users;
+ }
+
+ 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/manytomany/User.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/manytomany/User.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/manytomany/User.java 2007-07-26
13:44:25 UTC (rev 2677)
@@ -0,0 +1,46 @@
+//$Id: User.java 7085 2005-06-08 17:59:47Z oneovthafew $
+package mapping.manytomany;
+
+import java.io.Serializable;
+import java.util.HashSet;
+import java.util.Set;
+
+public class User implements Serializable {
+
+ private String org;
+ private String name;
+ private Set groups = new HashSet();
+
+ public User(String name, String org) {
+
this.org = org;
+ this.name = name;
+ }
+
+ public User() {
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getOrg() {
+ return org;
+ }
+
+ public void setOrg(String org) {
+
this.org = org;
+ }
+
+ public Set getGroups() {
+ return groups;
+ }
+
+ public void setGroups(Set groups) {
+ this.groups = groups;
+ }
+
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/manytomany/UserGroup.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/manytomany/UserGroup.hbm.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/manytomany/UserGroup.hbm.xml 2007-07-26
13:44:25 UTC (rev 2677)
@@ -0,0 +1,52 @@
+<?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 many-to-many
+ association with a shared attribute in the primary keys
+ of the associated entities.
+
+-->
+
+<hibernate-mapping
+ package="mapping.manytomany">
+
+ <class name="User" table="`User`">
+ <composite-id>
+ <key-property name="name"/>
+ <key-property name="org"/>
+ </composite-id>
+ <set name="groups" table="UserGroup">
+ <key>
+ <column name="userName"/>
+ <column name="org"/>
+ </key>
+ <many-to-many class="Group">
+ <column name="groupName"/>
+ <formula>org</formula>
+ </many-to-many>
+ </set>
+ </class>
+
+ <class name="Group" table="`Group`">
+ <composite-id>
+ <key-property name="name"/>
+ <key-property name="org"/>
+ </composite-id>
+ <property name="description"/>
+ <set name="users" table="UserGroup"
inverse="true">
+ <key>
+ <column name="groupName"/>
+ <column name="org"/>
+ </key>
+ <many-to-many class="User">
+ <column name="userName"/>
+ <formula>org</formula>
+ </many-to-many>
+ </set>
+ </class>
+
+</hibernate-mapping>
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/manytomany/ordered/Group.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/manytomany/ordered/Group.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/manytomany/ordered/Group.java 2007-07-26
13:44:25 UTC (rev 2677)
@@ -0,0 +1,69 @@
+package mapping.manytomany.ordered;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.ArrayList;
+
+public class Group implements Serializable {
+
+ private Long id;
+ private String org;
+ private String name;
+ private String description;
+
+ private List users = new ArrayList();
+
+ public Group() {
+ }
+
+ public Group(String name, String org) {
+
this.org = org;
+ 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 String getOrg() {
+ return org;
+ }
+
+ public void setOrg(String org) {
+
this.org = org;
+ }
+
+ public List getUsers() {
+ return users;
+ }
+
+ public void setUsers(List users) {
+ this.users = users;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public void addUser(User user) {
+ if ( user.getGroups().add( this ) ) {
+ getUsers().add( user );
+ }
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/manytomany/ordered/User.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/manytomany/ordered/User.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/manytomany/ordered/User.java 2007-07-26
13:44:25 UTC (rev 2677)
@@ -0,0 +1,54 @@
+package mapping.manytomany.ordered;
+
+import java.io.Serializable;
+import java.util.Set;
+import java.util.HashSet;
+
+public class User implements Serializable {
+
+ private Long id;
+ private String org;
+ private String name;
+ private Set groups = new HashSet();
+
+ public User() {
+ }
+
+ public User(String name, String org) {
+
this.org = org;
+ 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 String getOrg() {
+ return org;
+ }
+
+ public void setOrg(String org) {
+
this.org = org;
+ }
+
+ public Set getGroups() {
+ return groups;
+ }
+
+ public void setGroups(Set groups) {
+ this.groups = groups;
+ }
+
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/manytomany/ordered/UserGroup.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/manytomany/ordered/UserGroup.hbm.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/manytomany/ordered/UserGroup.hbm.xml 2007-07-26
13:44:25 UTC (rev 2677)
@@ -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">
+
+<!--
+
+ This mapping demonstrates how to map a many-to-many
+ association with a shared attribute in the primary keys
+ of the associated entities.
+
+-->
+
+<hibernate-mapping
+ package="mapping.manytomany.ordered">
+
+
+ <class name="User" table="`User`">
+ <id name="id" column="ID" type="long">
+ <generator class="native"/>
+ </id>
+ <property name="name" column="NAME"/>
+ <property name="org" column="ORG"/>
+ <set name="groups" table="UserGroup">
+ <key column="USER_ID"/>
+ <many-to-many column="GROUP_ID" class="Group"/>
+ </set>
+ </class>
+
+ <class name="Group" table="`Group`">
+ <id name="id" column="ID">
+ <generator class="native"/>
+ </id>
+ <property name="name"/>
+ <property name="description"/>
+ <bag name="users" table="UserGroup"
inverse="true">
+ <key column="GROUP_ID"/>
+ <many-to-many column="USER_ID" class="User"
order-by="NAME"/>
+ </bag>
+ </class>
+
+</hibernate-mapping>
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/map/Group.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/map/Group.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/map/Group.java 2007-07-26
13:44:25 UTC (rev 2677)
@@ -0,0 +1,29 @@
+//$Id: Group.java 5686 2005-02-12 07:27:32Z steveebersole $
+package mapping.map;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author Gavin King
+ */
+public class Group {
+ private String name;
+ private Map users = new HashMap();
+ Group() {}
+ public Group(String n) {
+ name = n;
+ }
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+ public Map getUsers() {
+ return users;
+ }
+ public void setUsers(Map users) {
+ this.users = users;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/map/SessionAttribute.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/map/SessionAttribute.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/map/SessionAttribute.java 2007-07-26
13:44:25 UTC (rev 2677)
@@ -0,0 +1,41 @@
+//$Id: SessionAttribute.java 5686 2005-02-12 07:27:32Z steveebersole $
+package mapping.map;
+
+import java.io.Serializable;
+
+/**
+ * @author Gavin King
+ */
+public class SessionAttribute {
+ private Long id;
+ private String name;
+ private String stringData;
+ private Serializable objectData;
+ SessionAttribute() {}
+ public SessionAttribute(String name, Serializable obj) {
+ this.name = name;
+ this.objectData = obj;
+ }
+ public SessionAttribute(String name, String str) {
+ this.name = name;
+ this.stringData = str;
+ }
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+ public Serializable getObjectData() {
+ return objectData;
+ }
+ public void setObjectData(Serializable objectData) {
+ this.objectData = objectData;
+ }
+ public String getStringData() {
+ return stringData;
+ }
+ public void setStringData(String stringData) {
+ this.stringData = stringData;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/map/User.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/map/User.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/map/User.java 2007-07-26
13:44:25 UTC (rev 2677)
@@ -0,0 +1,37 @@
+//$Id: User.java 5686 2005-02-12 07:27:32Z steveebersole $
+package mapping.map;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author Gavin King
+ */
+public class User {
+ private String name;
+ private String password;
+ private Map session = new HashMap();
+ User() {}
+ public User(String n, String pw) {
+ name=n;
+ password = pw;
+ }
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+ public String getPassword() {
+ return password;
+ }
+ public void setPassword(String password) {
+ this.password = password;
+ }
+ public Map getSession() {
+ return session;
+ }
+ public void setSession(Map session) {
+ this.session = session;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/map/UserGroup.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/map/UserGroup.hbm.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/map/UserGroup.hbm.xml 2007-07-26
13:44:25 UTC (rev 2677)
@@ -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">
+
+<!--
+
+-->
+
+<hibernate-mapping package="mapping.map">
+
+ <class name="Group" table="groups">
+ <id name="name"/>
+ <map name="users" cascade="persist"
table="group_user">
+ <key column="groupName"/>
+ <map-key formula="lower(personName)" type="string"/>
+ <many-to-many column="personName" class="User"/>
+ </map>
+ </class>
+
+ <class name="User" table="users">
+ <id name="name"/>
+ <property name="password"/>
+ <map name="session"
cascade="persist,save-update,delete,delete-orphan">
+ <key column="userName" not-null="true"/>
+ <map-key formula="lower(name)" type="string"/>
+ <one-to-many class="SessionAttribute"/>
+ </map>
+ </class>
+
+ <class name="SessionAttribute" table="session_attributes">
+ <id name="id" access="field">
+ <generator class="native"/>
+ </id>
+ <property name="name" not-null="true"
update="false"/>
+ <property name="stringData"/>
+ <property name="objectData"/>
+ </class>
+
+ <sql-query name="userSessionData">
+ <return alias="u" class="User"/>
+ <return-join alias="s" property="u.session"/>
+ select
+ lower(u.name) as {u.name}, lower(u.password) as {u.password},
+ lower(s.userName) as {s.key}, lower(s.name) as {s.index}, s.id as {s.element},
+ {s.element.*}
+ from users u
+ join session_attributes s on lower(s.userName) = lower(u.name)
+ where u.name like :uname
+ </sql-query>
+
+
+</hibernate-mapping>
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mapcompelem/Item.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mapcompelem/Item.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mapcompelem/Item.java 2007-07-26
13:44:25 UTC (rev 2677)
@@ -0,0 +1,35 @@
+//$Id: Item.java 6236 2005-03-29 03:20:23Z oneovthafew $
+package mapping.mapcompelem;
+
+/**
+ * @author Gavin King
+ */
+public class Item {
+
+ private String code;
+ private Product product;
+
+
+ Item() {}
+ public Item(String code, Product p) {
+ this.code = code;
+ this.product = p;
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ public void setCode(String code) {
+ this.code = code;
+ }
+
+ public Product getProduct() {
+ return product;
+ }
+
+ public void setProduct(Product product) {
+ this.product = product;
+ }
+
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mapcompelem/Part.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mapcompelem/Part.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mapcompelem/Part.java 2007-07-26
13:44:25 UTC (rev 2677)
@@ -0,0 +1,37 @@
+//$Id: Part.java 5686 2005-02-12 07:27:32Z steveebersole $
+package mapping.mapcompelem;
+
+
+/**
+ * @author Gavin King
+ */
+public class Part {
+ private String name;
+ private String description;
+ Part() {}
+ public Part(String n, String pw) {
+ name=n;
+ description = pw;
+ }
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+ public String getDescription() {
+ return description;
+ }
+ public void setDescription(String password) {
+ this.description = password;
+ }
+ public boolean equals(Object that) {
+ return ( (Part) that ).getName().equals(name);
+ }
+ public int hashCode() {
+ return name.hashCode();
+ }
+ public String toString() {
+ return name + ":" + description;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mapcompelem/Product.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mapcompelem/Product.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mapcompelem/Product.java 2007-07-26
13:44:25 UTC (rev 2677)
@@ -0,0 +1,29 @@
+//$Id: Product.java 5686 2005-02-12 07:27:32Z steveebersole $
+package mapping.mapcompelem;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author Gavin King
+ */
+public class Product {
+ private String name;
+ private Map parts = new HashMap();
+ Product() {}
+ public Product(String n) {
+ name = n;
+ }
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+ public Map getParts() {
+ return parts;
+ }
+ public void setParts(Map users) {
+ this.parts = users;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mapcompelem/ProductPart.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mapcompelem/ProductPart.hbm.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mapcompelem/ProductPart.hbm.xml 2007-07-26
13:44:25 UTC (rev 2677)
@@ -0,0 +1,31 @@
+<?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.mapcompelem">
+
+ <import class="Part"/>
+
+ <class name="Product" table="Products">
+ <id name="name" column="productName"/>
+ <map name="parts" table="Parts">
+ <key column="productName"/>
+ <map-key column="partName" type="string"/>
+ <composite-element class="Part">
+ <property name="name" formula="lower(partName)"/>
+ <property name="description" column="partDescription"/>
+ </composite-element>
+ </map>
+ </class>
+
+ <class name="Item" table="Items">
+ <id name="code"/>
+ <many-to-one name="product" column="productName"/>
+ </class>
+
+</hibernate-mapping>
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mapelemformula/Group.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mapelemformula/Group.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mapelemformula/Group.java 2007-07-26
13:44:25 UTC (rev 2677)
@@ -0,0 +1,29 @@
+//$Id: Group.java 5686 2005-02-12 07:27:32Z steveebersole $
+package mapping.mapelemformula;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author Gavin King
+ */
+public class Group {
+ private String name;
+ private Map users = new HashMap();
+ Group() {}
+ public Group(String n) {
+ name = n;
+ }
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+ public Map getUsers() {
+ return users;
+ }
+ public void setUsers(Map users) {
+ this.users = users;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mapelemformula/User.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mapelemformula/User.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mapelemformula/User.java 2007-07-26
13:44:25 UTC (rev 2677)
@@ -0,0 +1,28 @@
+//$Id: User.java 5686 2005-02-12 07:27:32Z steveebersole $
+package mapping.mapelemformula;
+
+
+/**
+ * @author Gavin King
+ */
+public class User {
+ private String name;
+ private String password;
+ User() {}
+ public User(String n, String pw) {
+ name=n;
+ password = pw;
+ }
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+ public String getPassword() {
+ return password;
+ }
+ public void setPassword(String password) {
+ this.password = password;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mapelemformula/UserGroup.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mapelemformula/UserGroup.hbm.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mapelemformula/UserGroup.hbm.xml 2007-07-26
13:44:25 UTC (rev 2677)
@@ -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.mapelemformula">
+
+ <class name="Group" table="groups">
+ <id name="name"/>
+ <map name="users" cascade="persist"
table="group_user">
+ <key column="groupName"/>
+ <map-key column="personName" type="string"/>
+ <many-to-many formula="lower(personName)" class="User"
fetch="select"/>
+ </map>
+ </class>
+
+ <class name="User" table="users">
+ <id name="name"/>
+ <property name="password"/>
+ </class>
+
+</hibernate-mapping>
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mappingexception/InvalidMapping.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mappingexception/InvalidMapping.hbm.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mappingexception/InvalidMapping.hbm.xml 2007-07-26
13:44:25 UTC (rev 2677)
@@ -0,0 +1,4 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping SYSTEM
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
+
+This File Intentionally Left Blank
\ No newline at end of file
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mappingexception/InvalidMapping.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mappingexception/InvalidMapping.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mappingexception/InvalidMapping.java 2007-07-26
13:44:25 UTC (rev 2677)
@@ -0,0 +1,5 @@
+package mapping.mappingexception;
+
+public class InvalidMapping {
+// This Class Intentionally Left Blank
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mappingexception/User.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mappingexception/User.hbm.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mappingexception/User.hbm.xml 2007-07-26
13:44:25 UTC (rev 2677)
@@ -0,0 +1,11 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping SYSTEM
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
+
+<hibernate-mapping package="mapping.mappingexception" >
+ <class name="User" table="T_USER" >
+ <id name="id" unsaved-value="null" column="user_id"
>
+ <generator class="native"/>
+ </id>
+ <property name="username" type="string"
column="user_name" />
+ </class>
+</hibernate-mapping>
\ No newline at end of file
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mappingexception/User.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mappingexception/User.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mappingexception/User.java 2007-07-26
13:44:25 UTC (rev 2677)
@@ -0,0 +1,31 @@
+// $Id: User.java 4746 2004-11-11 20:57:28Z steveebersole $
+package mapping.mappingexception;
+
+import java.util.Set;
+import java.util.HashSet;
+
+/**
+ *
+ *
+ * @author Max Rydahl Andersen
+ */
+public class User {
+ private Long id;
+ private String username;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ 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/mixed/Document.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mixed/Document.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mixed/Document.java 2007-07-26
13:44:25 UTC (rev 2677)
@@ -0,0 +1,83 @@
+//$Id: Document.java 8670 2005-11-25 17:36:29Z epbernard $
+
+package mapping.mixed;
+
+
+import java.sql.Blob;
+import java.util.Calendar;
+
+
+/**
+ * @author Gavin King
+ */
+
+public class Document extends Item {
+
+ private Blob content;
+
+ private Calendar modified;
+
+ private Calendar created;
+
+ /**
+ * @return Returns the created.
+ */
+
+ public Calendar getCreated() {
+
+ return created;
+
+ }
+
+ /**
+ * @param created The created to set.
+ */
+
+ public void setCreated(Calendar created) {
+
+ this.created = created;
+
+ }
+
+ /**
+ * @return Returns the modified.
+ */
+
+ public Calendar getModified() {
+
+ return modified;
+
+ }
+
+ /**
+ * @param modified The modified to set.
+ */
+
+ public void setModified(Calendar modified) {
+
+ this.modified = modified;
+
+ }
+
+ /**
+ * @return Returns the content.
+ */
+
+ public Blob getContent() {
+
+ return content;
+
+ }
+
+ /**
+ * @param content The content to set.
+ */
+
+ public void setContent(Blob content) {
+
+ this.content = content;
+
+ }
+
+}
+
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mixed/DocumentInterceptor.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mixed/DocumentInterceptor.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mixed/DocumentInterceptor.java 2007-07-26
13:44:25 UTC (rev 2677)
@@ -0,0 +1,116 @@
+//$Id: DocumentInterceptor.java 8670 2005-11-25 17:36:29Z epbernard $
+package mapping.mixed;
+
+import java.io.Serializable;
+import java.util.Calendar;
+import java.util.Iterator;
+
+import org.hibernate.CallbackException;
+import org.hibernate.EntityMode;
+import org.hibernate.Interceptor;
+import org.hibernate.Transaction;
+import org.hibernate.type.Type;
+
+/**
+ * @author Gavin King
+ */
+public class DocumentInterceptor implements Interceptor {
+
+
+ public boolean onLoad(
+ Object entity, Serializable id, Object[] state,
+ String[] propertyNames, Type[] types
+ ) throws CallbackException {
+ return false;
+ }
+
+ public boolean onFlushDirty(
+ Object entity, Serializable id,
+ Object[] currentState, Object[] previousState,
+ String[] propertyNames, Type[] types
+ ) throws CallbackException {
+ if ( entity instanceof Document ) {
+ currentState[3] = Calendar.getInstance();
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+
+ public boolean onSave(
+ Object entity, Serializable id, Object[] state,
+ String[] propertyNames, Type[] types
+ ) throws CallbackException {
+ if ( entity instanceof Document ) {
+ state[4] = state[3] = Calendar.getInstance();
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+
+ public void onDelete(
+ Object entity, Serializable id, Object[] state,
+ String[] propertyNames, Type[] types
+ ) throws CallbackException {
+
+ }
+
+ public void preFlush(Iterator entities) throws CallbackException {
+
+ }
+
+ public void postFlush(Iterator entities) throws CallbackException {
+
+ }
+
+ public Boolean isTransient(Object entity) {
+ return null;
+ }
+
+ public int[] findDirty(
+ Object entity, Serializable id,
+ Object[] currentState, Object[] previousState,
+ String[] propertyNames, Type[] types
+ ) {
+ return null;
+ }
+
+ public Object instantiate(String entityName, EntityMode entityMode, Serializable id)
throws CallbackException {
+ return null;
+ }
+
+ public String getEntityName(Object object) throws CallbackException {
+ return null;
+ }
+
+ public Object getEntity(String entityName, Serializable id)
+ throws CallbackException {
+ return null;
+ }
+
+ public void afterTransactionBegin(Transaction tx) {
+ }
+
+ public void afterTransactionCompletion(Transaction tx) {
+ }
+
+ public void beforeTransactionCompletion(Transaction tx) {
+ }
+
+ public String onPrepareStatement(String sql) {
+ return sql;
+ }
+
+ public void onCollectionRecreate(Object collection, Serializable key) throws
CallbackException {
+ }
+
+ public void onCollectionRemove(Object collection, Serializable key) throws
CallbackException {
+ }
+
+ public void onCollectionUpdate(Object collection, Serializable key) throws
CallbackException {
+ }
+
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mixed/Folder.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mixed/Folder.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mixed/Folder.java 2007-07-26
13:44:25 UTC (rev 2677)
@@ -0,0 +1,13 @@
+//$Id: Folder.java 8670 2005-11-25 17:36:29Z epbernard $
+
+package mapping.mixed;
+
+
+/**
+ * @author Gavin King
+ */
+
+public class Folder extends Item {
+
+}
+
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mixed/Item.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mixed/Item.hbm.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mixed/Item.hbm.xml 2007-07-26
13:44:25 UTC (rev 2677)
@@ -0,0 +1,135 @@
+<?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 a mixed inheritance strategy,
+
+ with one subclass acting like a joined-subclass via
+
+ use of a <join>. Also notice the fields which are initialized
+
+ by an interceptor.
+
+
+
+-->
+
+
+<hibernate-mapping
+
+ package="mapping.mixed">
+
+
+ <class name="Item"
+
+ table="Files"
+
+ discriminator-value="I">
+
+
+ <id name="id">
+
+ <generator class="native"/>
+
+ </id>
+
+
+ <discriminator type="character"
+
+ column="itemType"/>
+
+
+ <property name="name">
+
+ <column name="name"
+
+ not-null="true"
+
+ />
+ <!--unique-key="folder-parent"-->
+
+ </property>
+
+
+ <many-to-one name="parent"
+
+ class="Folder">
+
+ <column name="parentFolderId"
+
+ />
+ <!--unique-key="folder-parent"-->
+
+ </many-to-one>
+
+
+ <subclass name="Document"
+
+ discriminator-value="D"
+
+ lazy="true"
+
+ dynamic-update="true">
+
+
+ <property name="content"/>
+
+
+ <!-- managed by DocumentInterceptor -->
+
+ <property name="modified"/>
+
+ <property name="created"/>
+
+
+ <subclass name="SecureDocument"
+
+ discriminator-value="S"
+
+ dynamic-update="true"
+
+ lazy="true">
+
+
+ <join table="SecureDocument">
+
+
+ <key column="documentId"/>
+
+
+ <property name="permissionBits"
+
+ not-null="true"/>
+
+ <property name="owner"
+
+ not-null="true"/>
+
+
+ </join>
+
+
+ </subclass>
+
+
+ </subclass>
+
+
+ <subclass name="Folder"
+
+ discriminator-value="F"/>
+
+
+ </class>
+
+
+</hibernate-mapping>
\ No newline at end of file
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mixed/Item.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mixed/Item.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mixed/Item.java 2007-07-26
13:44:25 UTC (rev 2677)
@@ -0,0 +1,79 @@
+//$Id: Item.java 8670 2005-11-25 17:36:29Z epbernard $
+
+package mapping.mixed;
+
+
+/**
+ * @author Gavin King
+ */
+
+public abstract class Item {
+
+ private Long id;
+
+ private String name;
+
+ private Folder parent;
+
+ /**
+ * @return Returns the parent.
+ */
+
+ public Folder getParent() {
+
+ return parent;
+
+ }
+
+ /**
+ * @param parent The parent to set.
+ */
+
+ public void setParent(Folder parent) {
+
+ this.parent = parent;
+
+ }
+
+ /**
+ * @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/mixed/SecureDocument.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mixed/SecureDocument.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/mixed/SecureDocument.java 2007-07-26
13:44:25 UTC (rev 2677)
@@ -0,0 +1,57 @@
+//$Id: SecureDocument.java 8670 2005-11-25 17:36:29Z epbernard $
+
+package mapping.mixed;
+
+
+/**
+ * @author Gavin King
+ */
+
+public class SecureDocument extends Document {
+
+ private byte permissionBits;
+
+ private String owner;
+
+ /**
+ * @return Returns the owner.
+ */
+
+ public String getOwner() {
+
+ return owner;
+
+ }
+
+ /**
+ * @param owner The owner to set.
+ */
+
+ public void setOwner(String owner) {
+
+ this.owner = owner;
+
+ }
+
+ /**
+ * @return Returns the permissionBits.
+ */
+
+ public byte getPermissionBits() {
+
+ return permissionBits;
+
+ }
+
+ /**
+ * @param permissionBits The permissionBits to set.
+ */
+
+ public void setPermissionBits(byte permissionBits) {
+
+ this.permissionBits = permissionBits;
+
+ }
+
+}
+
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/naturalid/User.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/naturalid/User.hbm.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/naturalid/User.hbm.xml 2007-07-26
13:44:25 UTC (rev 2677)
@@ -0,0 +1,27 @@
+<?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 illustrates use of <natural-id>.
+
+-->
+
+<hibernate-mapping
+ package="mapping.naturalid"
+ default-access="field">
+
+ <class name="User" table="SystemUserInfo">
+ <id name="id">
+ <generator class="increment"/>
+ </id>
+ <natural-id>
+ <property name="name"/>
+ <property name="org"/>
+ </natural-id>
+ <property name="password"/>
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/naturalid/User.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/naturalid/User.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/naturalid/User.java 2007-07-26
13:44:25 UTC (rev 2677)
@@ -0,0 +1,34 @@
+//$Id: User.java 6900 2005-05-25 01:24:22Z oneovthafew $
+package mapping.naturalid;
+
+/**
+ * @author Gavin King
+ */
+public class User {
+
+ private Long id;
+ private String name;
+ private String org;
+ private String password;
+
+ User() {}
+
+ public User(String name, String org, String password) {
+ this.name = name;
+
this.org = org;
+ this.password = password;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public String getOrg() {
+ return org;
+ }
+
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/ondelete/Address.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/ondelete/Address.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/ondelete/Address.java 2007-07-26
13:44:25 UTC (rev 2677)
@@ -0,0 +1,11 @@
+//$Id: Address.java 7119 2005-06-12 22:03:30Z oneovthafew $
+package mapping.ondelete;
+
+/**
+ * @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/ondelete/Employee.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/ondelete/Employee.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/ondelete/Employee.java 2007-07-26
13:44:25 UTC (rev 2677)
@@ -0,0 +1,49 @@
+//$Id: Employee.java 7119 2005-06-12 22:03:30Z oneovthafew $
+package mapping.ondelete;
+
+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/ondelete/Person.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/ondelete/Person.hbm.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/ondelete/Person.hbm.xml 2007-07-26
13:44:25 UTC (rev 2677)
@@ -0,0 +1,67 @@
+<?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 the use of database-level
+ cascade delete.
+
+-->
+
+<hibernate-mapping
+ package="mapping.ondelete"
+ default-access="field">
+
+ <class name="Person" table="ODPerson">
+
+ <id name="id"
+ column="person_id">
+ <generator class="increment"/>
+ </id>
+
+ <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>
+
+ <many-to-one name="salesperson"
+ column="salesperson_id"/>
+
+ <joined-subclass name="Employee" table="ODEmployee">
+ <key column="person_id"
+ on-delete="cascade"/>
+ <property name="title"
+ not-null="true"
+ length="20"/>
+ <property name="salary"
+ length="0"/>
+ <many-to-one name="manager"/>
+
+ <joined-subclass name="Salesperson" table="ODSalesperson">
+ <key column="employee_id"
+ on-delete="cascade"/>
+ <set name="customers"
+ inverse="true"
+ cascade="all">
+ <key column="salesperson_id"
+ on-delete="cascade"/>
+ <one-to-many class="Person"/>
+ </set>
+ </joined-subclass>
+
+ </joined-subclass>
+
+ </class>
+
+
+</hibernate-mapping>
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/ondelete/Person.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/ondelete/Person.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/ondelete/Person.java 2007-07-26
13:44:25 UTC (rev 2677)
@@ -0,0 +1,79 @@
+//$Id: Person.java 7119 2005-06-12 22:03:30Z oneovthafew $
+package mapping.ondelete;
+
+
+/**
+ * @author Gavin King
+ */
+public class Person {
+ private long id;
+ private String name;
+ private char sex;
+ private Address address = new Address();
+ private Salesperson salesperson;
+ /**
+ * @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;
+ }
+
+ public Salesperson getSalesperson() {
+ return salesperson;
+ }
+
+ public void setSalesperson(Salesperson salesperson) {
+ this.salesperson = salesperson;
+ }
+
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/ondelete/Salesperson.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/ondelete/Salesperson.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/ondelete/Salesperson.java 2007-07-26
13:44:25 UTC (rev 2677)
@@ -0,0 +1,18 @@
+//$Id: Salesperson.java 7119 2005-06-12 22:03:30Z oneovthafew $
+package mapping.ondelete;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public class Salesperson extends Employee {
+ private Set customers = new HashSet();
+
+ public Set getCustomers() {
+ return customers;
+ }
+
+ public void setCustomers(Set customers) {
+ this.customers = customers;
+ }
+
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetomany/Child.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetomany/Child.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetomany/Child.java 2007-07-26
13:44:25 UTC (rev 2677)
@@ -0,0 +1,47 @@
+//$Id: Child.java 4378 2004-08-19 10:12:11Z oneovthafew $
+package mapping.onetomany;
+
+/**
+ * @author gavin
+ */
+public class Child {
+ private Long id;
+ private String name;
+ private Parent parent;
+ /**
+ * @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 parent.
+ */
+ public Parent getParent() {
+ return parent;
+ }
+ /**
+ * @param parent The parent to set.
+ */
+ public void setParent(Parent parent) {
+ this.parent = parent;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetomany/Parent.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetomany/Parent.hbm.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetomany/Parent.hbm.xml 2007-07-26
13:44:25 UTC (rev 2677)
@@ -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 how to use an "inverse" join
+ to map an association table as an association with
+ one-to-many multiplicity at the level of the object
+ model.
+
+-->
+
+<hibernate-mapping
+ package="mapping.onetomany">
+
+ <class name="Parent">
+ <id name="id"
+ column="parent_id">
+ <generator class="increment"/>
+ </id>
+ <property name="name"/>
+ <set name="children"
+ table="ParentChild"
+ cascade="all"
+ inverse="true">
+ <key column="parent_id"/>
+ <many-to-many column="child_id"
+ class="Child"/>
+ </set>
+ </class>
+
+ <class name="Child">
+ <id name="id"
+ column="child_id">
+ <generator class="increment"/>
+ </id>
+ <property name="name"/>
+ <join table="ParentChild"
+ optional="true">
+ <key column="child_id"/>
+ <many-to-one name="parent"
+ column="parent_id"
+ not-null="true"/>
+ </join>
+ </class>
+
+</hibernate-mapping>
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetomany/Parent.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetomany/Parent.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetomany/Parent.java 2007-07-26
13:44:25 UTC (rev 2677)
@@ -0,0 +1,50 @@
+//$Id: Parent.java 4378 2004-08-19 10:12:11Z oneovthafew $
+package mapping.onetomany;
+
+import java.util.Collection;
+import java.util.HashSet;
+
+/**
+ * @author gavin
+ */
+public class Parent {
+ private Long id;
+ private String name;
+ private Collection children = new HashSet();
+ /**
+ * @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/onetoone/formula/Address.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetoone/formula/Address.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetoone/formula/Address.java 2007-07-26
13:44:25 UTC (rev 2677)
@@ -0,0 +1,57 @@
+//$Id: Address.java 5686 2005-02-12 07:27:32Z steveebersole $
+package mapping.onetoone.formula;
+
+import java.io.Serializable;
+
+/**
+ * @author Gavin King
+ */
+public class Address implements Serializable {
+ private Person person;
+ private String type;
+ private String street;
+ private String state;
+ private String zip;
+
+ public Person getPerson() {
+ return person;
+ }
+ public void setPerson(Person person) {
+ this.person = person;
+ }
+ public String getState() {
+ return state;
+ }
+ public void setState(String state) {
+ this.state = state;
+ }
+ public String getStreet() {
+ return street;
+ }
+ public void setStreet(String street) {
+ this.street = street;
+ }
+ public String getType() {
+ return type;
+ }
+ public void setType(String type) {
+ this.type = type;
+ }
+ public String getZip() {
+ return zip;
+ }
+ public void setZip(String zip) {
+ this.zip = zip;
+ }
+
+ public boolean equals(Object that) {
+ if ( !(that instanceof Address) ) return false;
+ Address address = (Address) that;
+ return address.getType().equals(type) &&
+ address.getPerson().getName().equals( person.getName() );
+ }
+
+ public int hashCode() {
+ return person.getName().hashCode() + type.hashCode();
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetoone/formula/Person.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetoone/formula/Person.hbm.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetoone/formula/Person.hbm.xml 2007-07-26
13:44:25 UTC (rev 2677)
@@ -0,0 +1,33 @@
+<?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.onetoone.formula">
+
+ <class name="Person">
+ <id name="name"/>
+ <one-to-one name="address" cascade="all"
constrained="false">
+ <formula>name</formula>
+ <formula>'HOME'</formula>
+ </one-to-one>
+ <one-to-one name="mailingAddress" constrained="false">
+ <formula>name</formula>
+ <formula>'MAILING'</formula>
+ </one-to-one>
+ </class>
+
+ <class name="Address" batch-size="2"
+ check="addressType in ('MAILING', 'HOME',
'BUSINESS')">
+ <composite-id>
+ <key-many-to-one name="person"
+ column="personName"/>
+ <key-property name="type"
+ column="addressType"/>
+ </composite-id>
+ <property name="street" type="text"/>
+ <property name="state"/>
+ <property name="zip"/>
+ </class>
+
+</hibernate-mapping>
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetoone/formula/Person.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetoone/formula/Person.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetoone/formula/Person.java 2007-07-26
13:44:25 UTC (rev 2677)
@@ -0,0 +1,42 @@
+//$Id: Person.java 5686 2005-02-12 07:27:32Z steveebersole $
+package mapping.onetoone.formula;
+
+import java.io.Serializable;
+
+/**
+ * @author Gavin King
+ */
+public class Person implements Serializable {
+ private String name;
+ private Address address;
+ private Address mailingAddress;
+
+ public Address getAddress() {
+ return address;
+ }
+ public void setAddress(Address address) {
+ this.address = address;
+ }
+ public Address getMailingAddress() {
+ return mailingAddress;
+ }
+ public void setMailingAddress(Address mailingAddress) {
+ this.mailingAddress = mailingAddress;
+ }
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public boolean equals(Object that) {
+ if ( !(that instanceof Person) ) return false;
+ Person person = (Person) that;
+ return person.getName().equals(name);
+ }
+
+ public int hashCode() {
+ return name.hashCode();
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetoone/joined/Address.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetoone/joined/Address.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetoone/joined/Address.java 2007-07-26
13:44:25 UTC (rev 2677)
@@ -0,0 +1,16 @@
+//$Id: Address.java 9914 2006-05-09 09:37:18Z max.andersen(a)jboss.com $
+package mapping.onetoone.joined;
+
+/**
+ * @author Gavin King
+ */
+public class Address {
+ public String entityName;
+ public String street;
+ public String state;
+ public String zip;
+
+ public String toString() {
+ return this.getClass() + ":" + street;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetoone/joined/Entity.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetoone/joined/Entity.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetoone/joined/Entity.java 2007-07-26
13:44:25 UTC (rev 2677)
@@ -0,0 +1,9 @@
+//$Id: Entity.java 5686 2005-02-12 07:27:32Z steveebersole $
+package mapping.onetoone.joined;
+
+/**
+ * @author Gavin King
+ */
+public class Entity {
+ public String name;
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetoone/joined/Org.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetoone/joined/Org.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetoone/joined/Org.java 2007-07-26
13:44:25 UTC (rev 2677)
@@ -0,0 +1,9 @@
+//$Id: Org.java 5686 2005-02-12 07:27:32Z steveebersole $
+package mapping.onetoone.joined;
+
+
+/**
+ * @author Gavin King
+ */
+public class Org extends Entity {
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetoone/joined/Person.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetoone/joined/Person.hbm.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetoone/joined/Person.hbm.xml 2007-07-26
13:44:25 UTC (rev 2677)
@@ -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.onetoone.joined"
+ default-access="field">
+
+ <class name="Entity">
+ <id name="name"/>
+ <joined-subclass name="Person">
+ <key column="entityName"/>
+ <one-to-one name="address"
+ cascade="all"
+ constrained="true"/>
+ <one-to-one name="mailingAddress"
+ cascade="all"
+ entity-name="MailingAddress"/>
+ </joined-subclass>
+ <joined-subclass name="Org">
+ <key column="entityName"/>
+ </joined-subclass>
+ </class>
+
+ <class name="Address">
+ <id name="entityName"/>
+ <property name="street"/>
+ <property name="state"/>
+ <property name="zip"/>
+ </class>
+
+ <class name="Address" entity-name="MailingAddress">
+ <id name="entityName"/>
+ <property name="street"/>
+ <property name="state"/>
+ <property name="zip"/>
+ </class>
+
+</hibernate-mapping>
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetoone/joined/Person.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetoone/joined/Person.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetoone/joined/Person.java 2007-07-26
13:44:25 UTC (rev 2677)
@@ -0,0 +1,10 @@
+//$Id: Person.java 5686 2005-02-12 07:27:32Z steveebersole $
+package mapping.onetoone.joined;
+
+/**
+ * @author Gavin King
+ */
+public class Person extends Entity {
+ public Address address;
+ public Address mailingAddress;
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetoone/link/Customer.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetoone/link/Customer.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetoone/link/Customer.java 2007-07-26
13:44:25 UTC (rev 2677)
@@ -0,0 +1,22 @@
+//$Id: Customer.java 5686 2005-02-12 07:27:32Z steveebersole $
+package mapping.onetoone.link;
+
+/**
+ * @author Gavin King
+ */
+public class Customer {
+ private Long id;
+ private Person person;
+ public Person getPerson() {
+ return person;
+ }
+ public void setPerson(Person person) {
+ this.person = person;
+ }
+ public Long getId() {
+ return id;
+ }
+ public void setId(Long id) {
+ this.id = id;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetoone/link/Employee.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetoone/link/Employee.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetoone/link/Employee.java 2007-07-26
13:44:25 UTC (rev 2677)
@@ -0,0 +1,22 @@
+//$Id: Employee.java 5686 2005-02-12 07:27:32Z steveebersole $
+package mapping.onetoone.link;
+
+/**
+ * @author Gavin King
+ */
+public class Employee {
+ private Long id;
+ private Person person;
+ public Person getPerson() {
+ return person;
+ }
+ public void setPerson(Person person) {
+ this.person = person;
+ }
+ public Long getId() {
+ return id;
+ }
+ public void setId(Long id) {
+ this.id = id;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetoone/link/Person.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetoone/link/Person.hbm.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetoone/link/Person.hbm.xml 2007-07-26
13:44:25 UTC (rev 2677)
@@ -0,0 +1,69 @@
+<?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 mapping of two subtyping one-to-one relationships
+ to association tables using <many-to-one> nested inside <join>.
+ Note that the <join> elements specify optional="true", and that
+ there is an inverse="true" side of both joins.
+
+ -->
+
+<hibernate-mapping package="mapping.onetoone.link">
+
+ <class name="Person">
+ <id name="name"/>
+ <property name="dob" type="date"/>
+ <join table="employeePerson"
+ inverse="true"
+ optional="true">
+ <key column="personId" unique="true"/>
+ <many-to-one name="employee"
+ column="employeeId"
+ cascade="all"
+ not-null="true"/>
+ </join>
+ <join table="customerPerson"
+ inverse="true"
+ optional="true">
+ <key column="personId" unique="true"/>
+ <many-to-one name="customer"
+ column="customerId"
+ cascade="all"
+ not-null="true"/>
+ </join>
+ </class>
+
+ <class name="Employee">
+ <id name="id" column="employeeId">
+ <generator class="native"/>
+ </id>
+ <join table="employeePerson"
+ optional="true">
+ <key column="employeeId"/>
+ <many-to-one name="person"
+ column="personId"
+ cascade="all"
+ not-null="true"
+ unique="true"/>
+ </join>
+ </class>
+
+ <class name="Customer">
+ <id name="id" column="customerId">
+ <generator class="native"/>
+ </id>
+ <join table="customerPerson" optional="true">
+ <key column="customerId"/>
+ <many-to-one name="person"
+ column="personId"
+ cascade="all"
+ not-null="true"
+ unique="true"/>
+ </join>
+ </class>
+
+</hibernate-mapping>
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetoone/link/Person.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetoone/link/Person.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/onetoone/link/Person.java 2007-07-26
13:44:25 UTC (rev 2677)
@@ -0,0 +1,38 @@
+//$Id: Person.java 5686 2005-02-12 07:27:32Z steveebersole $
+package mapping.onetoone.link;
+
+import java.util.Date;
+
+/**
+ * @author Gavin King
+ */
+public class Person {
+ private String name;
+ private Date dob;
+ private Employee employee;
+ private Customer customer;
+ public Customer getCustomer() {
+ return customer;
+ }
+ public void setCustomer(Customer customer) {
+ this.customer = customer;
+ }
+ public Employee getEmployee() {
+ return employee;
+ }
+ public void setEmployee(Employee employee) {
+ this.employee = employee;
+ }
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+ public Date getDob() {
+ return dob;
+ }
+ public void setDob(Date dob) {
+ this.dob = dob;
+ }
+}