Author: mdryakhlenkov
Date: 2007-08-01 12:20:50 -0400 (Wed, 01 Aug 2007)
New Revision: 2809
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/typeparameters/DefaultValueIntegerType.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/typeparameters/Typedef.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/typeparameters/Widget.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/typeparameters/Widget.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unconstrained/Employee.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unconstrained/Person.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unconstrained/Person.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unidir/Child.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unidir/Parent.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unidir/ParentChild.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unionsubclass/Alien.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unionsubclass/Being.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unionsubclass/Beings.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unionsubclass/Employee.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unionsubclass/Hive.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unionsubclass/Human.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unionsubclass/Location.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unionsubclass/Thing.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unionsubclass2/Address.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unionsubclass2/Customer.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unionsubclass2/Employee.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unionsubclass2/Person.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unionsubclass2/Person.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/version/Person.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/version/PersonThing.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/version/Task.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/version/Thing.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/where/File.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/where/File.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/where/NumericTrueFalseType.java
Log:
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/typeparameters/DefaultValueIntegerType.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/typeparameters/DefaultValueIntegerType.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/typeparameters/DefaultValueIntegerType.java 2007-08-01
16:20:50 UTC (rev 2809)
@@ -0,0 +1,79 @@
+package mapping.typeparameters;
+
+import java.io.Serializable;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Types;
+import java.util.Properties;
+
+import org.hibernate.HibernateException;
+import org.hibernate.usertype.ParameterizedType;
+import org.hibernate.usertype.UserType;
+
+
+/**
+ * @author Michi
+ */
+public class DefaultValueIntegerType implements UserType, ParameterizedType, Serializable
{
+
+ private Integer defaultValue;
+
+ public int[] sqlTypes() {
+ return new int[] {Types.INTEGER};
+ }
+
+ public Class returnedClass() {
+ return int.class;
+ }
+
+ public boolean equals(Object x, Object y) throws HibernateException {
+ if (x==y) return true;
+ if (x==null || y==null) return false;
+ return x.equals(y);
+ }
+
+ public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws
HibernateException, SQLException {
+ Number result = (Number) rs.getObject(names[0]);
+ return result==null ? defaultValue : new Integer(result.intValue());
+ }
+
+ public void nullSafeSet(PreparedStatement st, Object value, int index) throws
HibernateException, SQLException {
+ if (value == null || defaultValue.equals(value) ) {
+ st.setNull(index, Types.INTEGER);
+ } else {
+ st.setInt(index, ((Integer)value).intValue());
+ }
+ }
+
+ public Object deepCopy(Object value) throws HibernateException {
+ return new Integer(((Integer)value).intValue());
+ }
+
+ public boolean isMutable() {
+ return false;
+ }
+
+ public int hashCode(Object x) throws HibernateException {
+ return x.hashCode();
+ }
+
+ public Object assemble(Serializable cached, Object owner)
+ throws HibernateException {
+ return cached;
+ }
+
+ public Serializable disassemble(Object value) throws HibernateException {
+ return (Serializable) value;
+ }
+
+ public Object replace(Object original, Object target, Object owner)
+ throws HibernateException {
+ return original;
+ }
+
+ public void setParameterValues(Properties parameters) {
+ this.defaultValue = Integer.valueOf((String) parameters.get("default"));
+ }
+
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/typeparameters/Typedef.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/typeparameters/Typedef.hbm.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/typeparameters/Typedef.hbm.xml 2007-08-01
16:20:50 UTC (rev 2809)
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping SYSTEM
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<hibernate-mapping>
+
+ <typedef name="nullToMinusOne"
+ class="mapping.typeparameters.DefaultValueIntegerType">
+ <param name="default">-1</param>
+ </typedef>
+
+</hibernate-mapping>
\ No newline at end of file
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/typeparameters/Widget.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/typeparameters/Widget.hbm.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/typeparameters/Widget.hbm.xml 2007-08-01
16:20:50 UTC (rev 2809)
@@ -0,0 +1,31 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping SYSTEM
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="mapping.typeparameters">
+
+ <typedef name="nullToTwo"
+ class="mapping.typeparameters.DefaultValueIntegerType">
+ <param name="default">2</param>
+ </typedef>
+
+ <class name="Widget" table="STRANGE_TYPED_OBJECT">
+ <id name="id" column="ID">
+ <generator class="increment"/>
+ </id>
+ <property name="valueOne" column="VALUE_ONE">
+ <type name="mapping.typeparameters.DefaultValueIntegerType">
+ <param name="default">1</param>
+ </type>
+ </property>
+ <property name="valueTwo" column="VALUE_TWO"
type="nullToTwo"/>
+ <property name="valueThree" column="VALUE_THREE"
type="nullToMinusOne"/>
+ <property name="valueFour" column="VALUE_FOUR">
+ <type name="nullToTwo">
+ <param name="default">-5</param>
+ </type>
+ </property>
+ <property name="string"/>
+ </class>
+
+
+</hibernate-mapping>
\ No newline at end of file
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/typeparameters/Widget.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/typeparameters/Widget.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/typeparameters/Widget.java 2007-08-01
16:20:50 UTC (rev 2809)
@@ -0,0 +1,62 @@
+package mapping.typeparameters;
+
+/**
+ * @author Michael Gloegl
+ */
+public class Widget {
+
+ private int valueOne = 1;
+ private int valueTwo = 2;
+ private int valueThree = -1;
+ private int valueFour = -5;
+ private Integer id;
+ private String string;
+
+ public int getValueOne() {
+ return valueOne;
+ }
+
+ public void setValueOne(int valueOne) {
+ this.valueOne = valueOne;
+ }
+
+ public int getValueThree() {
+ return valueThree;
+ }
+
+ public void setValueThree(int valueThree) {
+ this.valueThree = valueThree;
+ }
+
+ public int getValueTwo() {
+ return valueTwo;
+ }
+
+ public void setValueTwo(int valueTwo) {
+ this.valueTwo = valueTwo;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getString() {
+ return string;
+ }
+
+ public void setString(String string) {
+ this.string = string;
+ }
+
+ public int getValueFour() {
+ return valueFour;
+ }
+
+ public void setValueFour(int valueFour) {
+ this.valueFour = valueFour;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unconstrained/Employee.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unconstrained/Employee.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unconstrained/Employee.java 2007-08-01
16:20:50 UTC (rev 2809)
@@ -0,0 +1,28 @@
+//$Id: Employee.java 6298 2005-04-03 03:56:22Z oneovthafew $
+package mapping.unconstrained;
+
+/**
+ * @author Gavin King
+ */
+public class Employee {
+
+ private String id;
+
+ public Employee() {
+ }
+
+ public Employee(String id) {
+ this.id = id;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unconstrained/Person.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unconstrained/Person.hbm.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unconstrained/Person.hbm.xml 2007-08-01
16:20:50 UTC (rev 2809)
@@ -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.unconstrained"
+ default-access="field">
+
+ <class name="Person"
+ dynamic-update="true">
+
+ <id name="name"/>
+
+ <property name="employeeId"
+ unique="true"/>
+
+ <many-to-one name="employee"
+ formula="employeeId"
+ not-found="ignore"
+ cascade="all"/>
+
+ </class>
+
+ <class name="Employee">
+
+ <id name="id"/>
+
+ </class>
+
+</hibernate-mapping>
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unconstrained/Person.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unconstrained/Person.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unconstrained/Person.java 2007-08-01
16:20:50 UTC (rev 2809)
@@ -0,0 +1,43 @@
+//$Id: Person.java 6298 2005-04-03 03:56:22Z oneovthafew $
+package mapping.unconstrained;
+
+/**
+ * @author Gavin King
+ */
+public class Person {
+
+ private String name;
+ private String employeeId;
+ private Employee employee;
+
+ public Person() {}
+ public Person(String name) {
+ this.name = name;
+ }
+
+ public Employee getEmployee() {
+ return employee;
+ }
+
+ public void setEmployee(Employee employee) {
+ this.employee = employee;
+ }
+
+ public String getEmployeeId() {
+ return employeeId;
+ }
+
+ public void setEmployeeId(String employeeId) {
+ this.employeeId = employeeId;
+ }
+
+ 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/unidir/Child.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unidir/Child.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unidir/Child.java 2007-08-01
16:20:50 UTC (rev 2809)
@@ -0,0 +1,27 @@
+//$Id: Child.java 5686 2005-02-12 07:27:32Z steveebersole $
+package mapping.unidir;
+
+
+/**
+ * @author Gavin King
+ */
+public class Child {
+ private String name;
+ private int age;
+ Child() {}
+ public Child(String name) {
+ this.name = name;
+ }
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+ public int getAge() {
+ return age;
+ }
+ public void setAge(int age) {
+ this.age = age;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unidir/Parent.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unidir/Parent.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unidir/Parent.java 2007-08-01
16:20:50 UTC (rev 2809)
@@ -0,0 +1,29 @@
+//$Id: Parent.java 5686 2005-02-12 07:27:32Z steveebersole $
+package mapping.unidir;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Gavin King
+ */
+public class Parent {
+ private String name;
+ private List children = new ArrayList();
+ Parent() {}
+ public Parent(String name) {
+ this.name = name;
+ }
+ public List getChildren() {
+ return children;
+ }
+ public void setChildren(List children) {
+ this.children = children;
+ }
+ 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/unidir/ParentChild.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unidir/ParentChild.hbm.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unidir/ParentChild.hbm.xml 2007-08-01
16:20:50 UTC (rev 2809)
@@ -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.unidir">
+
+ <class name="Parent">
+ <id name="name"/>
+ <list name="children" cascade="persist,merge">
+ <key column="parentName" not-null="true"/>
+ <list-index column="sibling"/>
+ <one-to-many class="Child"/>
+ </list>
+ </class>
+
+ <class name="Child">
+ <id name="name"/>
+ <property name="age" not-null="true"/>
+ </class>
+
+</hibernate-mapping>
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unionsubclass/Alien.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unionsubclass/Alien.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unionsubclass/Alien.java 2007-08-01
16:20:50 UTC (rev 2809)
@@ -0,0 +1,38 @@
+//$Id: Alien.java 5686 2005-02-12 07:27:32Z steveebersole $
+package mapping.unionsubclass;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Gavin King
+ */
+public class Alien extends Being {
+ private String species;
+ private Hive hive;
+ private List hivemates = new ArrayList();
+ /**
+ * @return Returns the species.
+ */
+ public String getSpecies() {
+ return species;
+ }
+ /**
+ * @param species The species to set.
+ */
+ public void setSpecies(String species) {
+ this.species = species;
+ }
+ public Hive getHive() {
+ return hive;
+ }
+ public void setHive(Hive hive) {
+ this.hive = hive;
+ }
+ public List getHivemates() {
+ return hivemates;
+ }
+ public void setHivemates(List hivemates) {
+ this.hivemates = hivemates;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unionsubclass/Being.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unionsubclass/Being.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unionsubclass/Being.java 2007-08-01
16:20:50 UTC (rev 2809)
@@ -0,0 +1,72 @@
+//$Id: Being.java 6007 2005-03-04 12:01:43Z oneovthafew $
+package mapping.unionsubclass;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Gavin King
+ */
+public abstract class Being {
+ private long id;
+ private String identity;
+ private Location location;
+ private List things = new ArrayList();
+ private Map info = new HashMap();
+ /**
+ * @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 getIdentity() {
+ return identity;
+ }
+ /**
+ * @param identity The identity to set.
+ */
+ public void setIdentity(String identity) {
+ this.identity = identity;
+ }
+ /**
+ * @return Returns the location.
+ */
+ public Location getLocation() {
+ return location;
+ }
+ /**
+ * @param location The location to set.
+ */
+ public void setLocation(Location location) {
+ this.location = location;
+ }
+ public String getSpecies() {
+ return null;
+ }
+
+ public List getThings() {
+ return things;
+ }
+ public void setThings(List things) {
+ this.things = things;
+ }
+ public Map getInfo() {
+ return info;
+ }
+
+ public void setInfo(Map info) {
+ this.info = info;
+ }
+
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unionsubclass/Beings.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unionsubclass/Beings.hbm.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unionsubclass/Beings.hbm.xml 2007-08-01
16:20:50 UTC (rev 2809)
@@ -0,0 +1,113 @@
+<?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.unionsubclass"
+ default-access="field">
+
+ <class name="Being" abstract="true">
+
+ <id name="id" unsaved-value="0" column="bid">
+ <generator class="increment"/>
+ <!--generator class="hilo">
+ <param name="table">being_id</param>
+ <param name="column">next_id</param>
+ </generator-->
+ </id>
+
+ <property name="identity" not-null="true"
column="ident"/>
+ <many-to-one name="location" not-null="true"/>
+
+ <bag name="things" inverse="true">
+ <key column="owner"/>
+ <one-to-many class="Thing"/>
+ </bag>
+
+ <map name="info">
+ <key column="bid"/>
+ <map-key type="string" column="attribute"/>
+ <element type="string" column="value"/>
+ </map>
+
+ <union-subclass name="Human" table="humans">
+ <property name="sex"
+ not-null="true"
+ update="false"/>
+ <union-subclass name="Employee" table="employees">
+ <property name="salary"/>
+ </union-subclass>
+ </union-subclass>
+
+ <union-subclass name="Alien" table="aliens">
+ <property name="species"
+ not-null="true"
+ update="false"/>
+ <many-to-one name="hive" not-null="true"/>
+ <bag name="hivemates">
+ <key column="alien1"/>
+ <many-to-many column="alien2" class="Alien"/>
+ </bag>
+ </union-subclass>
+
+ </class>
+
+ <class name="Hive" table="hives">
+
+ <id name="id" unsaved-value="0">
+ <generator class="increment"/>
+ <!--generator class="hilo">
+ <param name="table">location_id</param>
+ <param name="column">next_id</param>
+ </generator-->
+ </id>
+
+ <many-to-one name="location" not-null="true"/>
+
+ <bag name="members"
+ inverse="true"
+ cascade="all,delete-orphan">
+ <key column="hive"/>
+ <one-to-many class="Alien"/>
+ </bag>
+
+ </class>
+
+ <class name="Location" table="locations">
+
+ <id name="id" unsaved-value="0">
+ <generator class="increment"/>
+ <!--generator class="hilo">
+ <param name="table">location_id</param>
+ <param name="column">next_id</param>
+ </generator-->
+ </id>
+
+ <property name="name" not-null="true"/>
+
+ <bag name="beings"
+ inverse="true"
+ cascade="all">
+ <key column="location"/>
+ <one-to-many class="Being"/>
+ </bag>
+
+ </class>
+
+ <class name="Thing" table="things">
+
+ <id name="id" unsaved-value="0">
+ <generator class="increment"/>
+ <!--generator class="hilo">
+ <param name="table">thing_id</param>
+ <param name="column">next_id</param>
+ </generator-->
+ </id>
+
+ <property name="description"/>
+ <many-to-one name="owner"/>
+
+ </class>
+
+</hibernate-mapping>
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unionsubclass/Employee.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unionsubclass/Employee.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unionsubclass/Employee.java 2007-08-01
16:20:50 UTC (rev 2809)
@@ -0,0 +1,17 @@
+//$Id: Employee.java 6673 2005-05-03 22:59:24Z epbernard $
+package mapping.unionsubclass;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class Employee extends Human {
+ private Double salary;
+
+ public Double getSalary() {
+ return salary;
+ }
+
+ public void setSalary(Double salary) {
+ this.salary = salary;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unionsubclass/Hive.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unionsubclass/Hive.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unionsubclass/Hive.java 2007-08-01
16:20:50 UTC (rev 2809)
@@ -0,0 +1,32 @@
+//$Id: Hive.java 5686 2005-02-12 07:27:32Z steveebersole $
+package mapping.unionsubclass;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Gavin King
+ */
+public class Hive {
+ private long id;
+ private Location location;
+ private List members = new ArrayList();
+ public List getMembers() {
+ return members;
+ }
+ public void setMembers(List hives) {
+ this.members = hives;
+ }
+ public long getId() {
+ return id;
+ }
+ public void setId(long id) {
+ this.id = id;
+ }
+ public Location getLocation() {
+ return location;
+ }
+ public void setLocation(Location location) {
+ this.location = location;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unionsubclass/Human.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unionsubclass/Human.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unionsubclass/Human.java 2007-08-01
16:20:50 UTC (rev 2809)
@@ -0,0 +1,26 @@
+//$Id: Human.java 4364 2004-08-17 12:10:32Z oneovthafew $
+package mapping.unionsubclass;
+
+/**
+ * @author Gavin King
+ */
+public class Human extends Being {
+ private char sex;
+
+ /**
+ * @return Returns the sex.
+ */
+ public char getSex() {
+ return sex;
+ }
+ /**
+ * @param sex The sex to set.
+ */
+ public void setSex(char sex) {
+ this.sex = sex;
+ }
+ public String getSpecies() {
+ return "human";
+ }
+
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unionsubclass/Location.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unionsubclass/Location.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unionsubclass/Location.java 2007-08-01
16:20:50 UTC (rev 2809)
@@ -0,0 +1,61 @@
+//$Id: Location.java 4357 2004-08-17 09:20:17Z oneovthafew $
+package mapping.unionsubclass;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+/**
+ * @author Gavin King
+ */
+public class Location {
+ private long id;
+ private String name;
+ private Collection beings = new ArrayList();
+
+ Location() {}
+
+ public Location(String name) {
+ this.name = name;
+ }
+
+ public void addBeing(Being b) {
+ b.setLocation(this);
+ beings.add(b);
+ }
+ /**
+ * @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 beings.
+ */
+ public Collection getBeings() {
+ return beings;
+ }
+ /**
+ * @param beings The beings to set.
+ */
+ public void setBeings(Collection beings) {
+ this.beings = beings;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unionsubclass/Thing.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unionsubclass/Thing.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unionsubclass/Thing.java 2007-08-01
16:20:50 UTC (rev 2809)
@@ -0,0 +1,47 @@
+//$Id: Thing.java 4418 2004-08-22 13:38:16Z oneovthafew $
+package mapping.unionsubclass;
+
+/**
+ * @author Gavin King
+ */
+public class Thing {
+ private long id;
+ private String description;
+ private Being owner;
+ /**
+ * @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 id.
+ */
+ public long getId() {
+ return id;
+ }
+ /**
+ * @param id The id to set.
+ */
+ public void setId(long id) {
+ this.id = id;
+ }
+ /**
+ * @return Returns the owner.
+ */
+ public Being getOwner() {
+ return owner;
+ }
+ /**
+ * @param owner The owner to set.
+ */
+ public void setOwner(Being owner) {
+ this.owner = owner;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unionsubclass2/Address.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unionsubclass2/Address.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unionsubclass2/Address.java 2007-08-01
16:20:50 UTC (rev 2809)
@@ -0,0 +1,11 @@
+//$Id: Address.java 7192 2005-06-18 14:40:15Z oneovthafew $
+package mapping.unionsubclass2;
+
+/**
+ * @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/unionsubclass2/Customer.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unionsubclass2/Customer.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unionsubclass2/Customer.java 2007-08-01
16:20:50 UTC (rev 2809)
@@ -0,0 +1,35 @@
+//$Id: Customer.java 7192 2005-06-18 14:40:15Z oneovthafew $
+package mapping.unionsubclass2;
+
+/**
+ * @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/unionsubclass2/Employee.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unionsubclass2/Employee.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unionsubclass2/Employee.java 2007-08-01
16:20:50 UTC (rev 2809)
@@ -0,0 +1,49 @@
+//$Id: Employee.java 7192 2005-06-18 14:40:15Z oneovthafew $
+package mapping.unionsubclass2;
+
+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/unionsubclass2/Person.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unionsubclass2/Person.hbm.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unionsubclass2/Person.hbm.xml 2007-08-01
16:20:50 UTC (rev 2809)
@@ -0,0 +1,61 @@
+<?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) a table-per-subclass mapping strategy
+
+ (2) a simple component mapping
+
+ (3) recursive associations withing an inheritance tree
+
+-->
+
+<hibernate-mapping
+ package="mapping.unionsubclass2"
+ default-access="field">
+
+ <class name="Person" table="UPerson">
+
+ <id name="id"
+ column="person_id"
+ unsaved-value="0">
+ <generator class="increment"/>
+ </id>
+
+ <property name="name"
+ unique-key="NameUniqueKey"
+ not-null="true"
+ length="80"/>
+ <property name="sex"
+ not-null="true"
+ update="false"/>
+
+ <component name="address">
+ <property name="address" index="AddressIndex"/>
+ <property name="zip" index="AddressIndex"/>
+ <property name="country"/>
+ </component>
+
+ <union-subclass name="Employee" table="UEmployee">
+ <property name="title"
+ not-null="true"
+ length="20"/>
+ <property name="salary"
+ length="0"/>
+ <many-to-one name="manager"/>
+ </union-subclass>
+
+ <union-subclass name="Customer" table="UCustomer">
+ <property name="comments"/>
+ <many-to-one name="salesperson"/>
+ </union-subclass>
+
+ </class>
+
+
+</hibernate-mapping>
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unionsubclass2/Person.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unionsubclass2/Person.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unionsubclass2/Person.java 2007-08-01
16:20:50 UTC (rev 2809)
@@ -0,0 +1,70 @@
+//$Id: Person.java 7192 2005-06-18 14:40:15Z oneovthafew $
+package mapping.unionsubclass2;
+
+
+/**
+ * @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;
+ }
+
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/version/Person.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/version/Person.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/version/Person.java 2007-08-01
16:20:50 UTC (rev 2809)
@@ -0,0 +1,43 @@
+//$Id: Person.java 7676 2005-07-29 06:27:10Z oneovthafew $
+package mapping.version;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class Person {
+ private String name;
+ private List things;
+ private List tasks;
+ private int version;
+
+ Person() {}
+ public Person(String name) {
+ this.name = name;
+ this.things = new ArrayList();
+ this.tasks = new ArrayList();
+ }
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+ public List getThings() {
+ return things;
+ }
+ public void setThings(List things) {
+ this.things = things;
+ }
+ public int getVersion() {
+ return version;
+ }
+ public void setVersion(int version) {
+ this.version = version;
+ }
+ public List getTasks() {
+ return tasks;
+ }
+ public void setTasks(List tasks) {
+ this.tasks = tasks;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/version/PersonThing.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/version/PersonThing.hbm.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/version/PersonThing.hbm.xml 2007-08-01
16:20:50 UTC (rev 2809)
@@ -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">
+
+<!--
+ Demonstrates how to control the optimistic locking behavior
+ of a collection (do changes to the collection result in
+ a version increment on the owning instance)
+ -->
+<hibernate-mapping
+ package="mapping.version">
+
+ <class name="Person">
+ <id name="name"/>
+ <version name="version"/>
+ <bag name="things"
+ inverse="true"
+ cascade="all,delete-orphan">
+ <key column="person"/>
+ <one-to-many class="Thing"/>
+ </bag>
+ <bag name="tasks"
+ inverse="true"
+ cascade="all,delete-orphan"
+ optimistic-lock="false">
+ <key column="person"/>
+ <one-to-many class="Task"/>
+ </bag>
+ </class>
+
+ <class name="Thing">
+ <id name="description"/>
+ <version name="version"/>
+ <property name="longDescription"/>
+ <many-to-one name="person"/>
+ </class>
+
+ <class name="Task">
+ <id name="description"/>
+ <version name="version"/>
+ <many-to-one name="person"/>
+ </class>
+
+</hibernate-mapping>
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/version/Task.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/version/Task.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/version/Task.java 2007-08-01
16:20:50 UTC (rev 2809)
@@ -0,0 +1,33 @@
+//$Id: Task.java 7676 2005-07-29 06:27:10Z oneovthafew $
+package mapping.version;
+
+public class Task {
+ private String description;
+ private Person person;
+ private int version;
+
+ public int getVersion() {
+ return version;
+ }
+ public void setVersion(int version) {
+ this.version = version;
+ }
+ Task() {}
+ public Task(String description, Person person) {
+ this.description = description;
+ this.person = person;
+ person.getTasks().add(this);
+ }
+ public String getDescription() {
+ return description;
+ }
+ public void setDescription(String description) {
+ this.description = description;
+ }
+ public Person getPerson() {
+ return person;
+ }
+ public void setPerson(Person person) {
+ this.person = person;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/version/Thing.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/version/Thing.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/version/Thing.java 2007-08-01
16:20:50 UTC (rev 2809)
@@ -0,0 +1,40 @@
+//$Id: Thing.java 7715 2005-08-01 16:46:57Z oneovthafew $
+package mapping.version;
+
+public class Thing {
+ private String description;
+ private Person person;
+ private int version;
+ private String longDescription;
+
+ public int getVersion() {
+ return version;
+ }
+ public void setVersion(int version) {
+ this.version = version;
+ }
+ Thing() {}
+ public Thing(String description, Person person) {
+ this.description = description;
+ this.person = person;
+ person.getThings().add(this);
+ }
+ public String getDescription() {
+ return description;
+ }
+ public void setDescription(String description) {
+ this.description = description;
+ }
+ public Person getPerson() {
+ return person;
+ }
+ public void setPerson(Person person) {
+ this.person = person;
+ }
+ public String getLongDescription() {
+ return longDescription;
+ }
+ public void setLongDescription(String longDescription) {
+ this.longDescription = longDescription;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/where/File.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/where/File.hbm.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/where/File.hbm.xml 2007-08-01
16:20:50 UTC (rev 2809)
@@ -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">
+
+<!--
+ Demonstrates use of a class-level where restriction
+ -->
+<hibernate-mapping package="mapping.where">
+
+ <class name="File" where="deleted=0"
table="T_FILE">
+ <id name="id">
+ <generator class="increment"/>
+ </id>
+ <property name="name"/>
+ <property name="deleted"
type="mapping.where.NumericTrueFalseType"/>
+ <many-to-one name="parent"/>
+ <set name="children" inverse="true"
where="deleted=0">
+ <key column="parent"/>
+ <one-to-many class="File"/>
+ </set>
+ </class>
+
+</hibernate-mapping>
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/where/File.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/where/File.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/where/File.java 2007-08-01
16:20:50 UTC (rev 2809)
@@ -0,0 +1,52 @@
+//$Id: File.java 8043 2005-08-30 15:20:42Z oneovthafew $
+package mapping.where;
+
+import java.util.Set;
+
+public class File {
+ private long id;
+ private String name;
+ private File parent;
+ private boolean deleted;
+ private Set children;
+
+ public Set getChildren() {
+ return children;
+ }
+ public void setChildren(Set children) {
+ this.children = children;
+ }
+
+ public File(String name, File parent) {
+ this.name = name;
+ this.parent = parent;
+ }
+
+ File() {}
+
+ public boolean isDeleted() {
+ return deleted;
+ }
+ public void setDeleted(boolean deleted) {
+ this.deleted = deleted;
+ }
+ 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 File getParent() {
+ return parent;
+ }
+ public void setParent(File parent) {
+ this.parent = parent;
+ }
+
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/where/NumericTrueFalseType.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/where/NumericTrueFalseType.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/where/NumericTrueFalseType.java 2007-08-01
16:20:50 UTC (rev 2809)
@@ -0,0 +1,53 @@
+package mapping.where;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.PreparedStatement;
+import java.sql.Types;
+
+import org.hibernate.type.BooleanType;
+import org.hibernate.dialect.Dialect;
+
+/**
+ * Maps int db values to boolean java values. Zero is considered false; any
+ * non-zero value is considered true.
+ *
+ * @author Steve Ebersole
+ */
+public class NumericTrueFalseType extends BooleanType {
+
+ public Object get(ResultSet rs, String name) throws SQLException {
+ int value = rs.getInt( name );
+ if ( rs.wasNull() ) {
+ return getDefaultValue();
+ }
+ else if ( value == 0 ) {
+ return Boolean.FALSE;
+ }
+ else {
+ return Boolean.TRUE;
+ }
+ }
+
+ public void set(PreparedStatement st, Object value, int index) throws SQLException {
+ if ( value == null ) {
+ st.setNull( index, Types.INTEGER );
+ }
+ else {
+ boolean bool = ( ( Boolean ) value ).booleanValue();
+ st.setInt( index, bool ? 1 : 0 );
+ }
+ }
+
+ public String objectToSQLString(Object value, Dialect dialect) throws Exception {
+ return ( ( Boolean ) value ).booleanValue() ? "1" : "0";
+ }
+
+ public int sqlType() {
+ return Types.INTEGER;
+ }
+
+ public String getName() {
+ return "numeric_boolean";
+ }
+}