Author: mdryakhlenkov
Date: 2007-08-01 12:19:55 -0400 (Wed, 01 Aug 2007)
New Revision: 2808
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/typeparameters/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unconstrained/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unidir/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unionsubclass/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/unionsubclass2/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/basic/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/basic/Email.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/basic/IMyList.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/basic/MyList.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/basic/MyListType.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/basic/PersistentMyList.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/basic/User.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/basic/UserPermissions.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/parameterized/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/parameterized/DefaultableList.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/parameterized/DefaultableListImpl.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/parameterized/DefaultableListType.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/parameterized/Entity.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/parameterized/Mapping.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/parameterized/PersistentDefaultableList.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/util/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/util/dtd/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/util/dtd/Child.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/util/dtd/Parent.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/util/dtd/Parent.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/util/dtd/child.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/version/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/version/db/
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/version/db/Group.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/version/db/Permission.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/version/db/User.hbm.xml
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/version/db/User.java
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/where/
Log:
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/basic/Email.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/basic/Email.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/basic/Email.java 2007-08-01
16:19:55 UTC (rev 2808)
@@ -0,0 +1,39 @@
+//$Id$
+package mapping.usercollection.basic;
+
+/**
+ * @author Gavin King
+ */
+public class Email {
+
+ private Long id;
+ private String address;
+
+ Email() {}
+
+ public String getAddress() {
+ return address;
+ }
+ public void setAddress(String type) {
+ this.address = type;
+ }
+ public Email(String type) {
+ this.address = type;
+ }
+ public boolean equals(Object that) {
+ if ( !(that instanceof Email) ) return false;
+ Email p = (Email) that;
+ return this.address.equals(p.address);
+ }
+ public int hashCode() {
+ return address.hashCode();
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ private void setId(Long id) {
+ this.id = id;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/basic/IMyList.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/basic/IMyList.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/basic/IMyList.java 2007-08-01
16:19:55 UTC (rev 2808)
@@ -0,0 +1,7 @@
+package mapping.usercollection.basic;
+
+import java.util.List;
+
+public interface IMyList extends List {
+
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/basic/MyList.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/basic/MyList.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/basic/MyList.java 2007-08-01
16:19:55 UTC (rev 2808)
@@ -0,0 +1,14 @@
+package mapping.usercollection.basic;
+
+import java.util.ArrayList;
+
+/**
+ * A custom collection class. We extend a java.util.Collection class, but that is not
required.
+ * It could be totally non-java-collection type, but then we would need to implement all
the PersistentCollection methods.
+ *
+ * @author max
+ *
+ */
+public class MyList extends ArrayList implements IMyList {
+
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/basic/MyListType.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/basic/MyListType.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/basic/MyListType.java 2007-08-01
16:19:55 UTC (rev 2808)
@@ -0,0 +1,65 @@
+package mapping.usercollection.basic;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import org.hibernate.EntityMode;
+import org.hibernate.HibernateException;
+import org.hibernate.collection.PersistentCollection;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.persister.collection.CollectionPersister;
+import org.hibernate.usertype.UserCollectionType;
+
+public class MyListType implements UserCollectionType {
+
+ static int lastInstantiationRequest = -2;
+
+ public PersistentCollection instantiate(SessionImplementor session, CollectionPersister
persister) throws HibernateException {
+ return new PersistentMyList(session);
+ }
+
+ public PersistentCollection wrap(SessionImplementor session, Object collection) {
+ if ( session.getEntityMode()==EntityMode.DOM4J ) {
+ throw new IllegalStateException("dom4j not supported");
+ }
+ else {
+ return new PersistentMyList( session, (IMyList) collection );
+ }
+ }
+
+ public Iterator getElementsIterator(Object collection) {
+ return ( (IMyList) collection ).iterator();
+ }
+
+ public boolean contains(Object collection, Object entity) {
+ return ( (IMyList) collection ).contains(entity);
+ }
+
+ public Object indexOf(Object collection, Object entity) {
+ int l = ( (IMyList) collection ).indexOf(entity);
+ if(l<0) {
+ return null;
+ } else {
+ return new Integer(l);
+ }
+ }
+
+ public Object replaceElements(Object original, Object target, CollectionPersister
persister, Object owner, Map copyCache, SessionImplementor session) throws
HibernateException {
+ IMyList result = (IMyList) target;
+ result.clear();
+ result.addAll((MyList)original);
+ return result;
+ }
+
+ public Object instantiate(int anticipatedSize) {
+ lastInstantiationRequest = anticipatedSize;
+ return new MyList();
+ }
+
+ public Object instantiate() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/basic/PersistentMyList.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/basic/PersistentMyList.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/basic/PersistentMyList.java 2007-08-01
16:19:55 UTC (rev 2808)
@@ -0,0 +1,18 @@
+package mapping.usercollection.basic;
+
+import org.hibernate.collection.PersistentList;
+import org.hibernate.engine.SessionImplementor;
+
+public class PersistentMyList extends PersistentList implements IMyList {
+
+ public PersistentMyList(SessionImplementor session) {
+ super(session);
+ }
+
+ public PersistentMyList(SessionImplementor session, IMyList list) {
+ super(session, list);
+ }
+
+
+
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/basic/User.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/basic/User.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/basic/User.java 2007-08-01
16:19:55 UTC (rev 2808)
@@ -0,0 +1,39 @@
+//$Id$
+package mapping.usercollection.basic;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Gavin King
+ */
+public class User {
+ private String userName;
+ private IMyList emailAddresses = new MyList();
+ private Map sessionData = new HashMap();
+
+ User() {}
+ public User(String name) {
+ userName = name;
+ }
+
+ public String getUserName() {
+ return userName;
+ }
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+ public List getEmailAddresses() {
+ return emailAddresses;
+ }
+ public void setEmailAddresses(IMyList emailAddresses) {
+ this.emailAddresses = emailAddresses;
+ }
+ public Map getSessionData() {
+ return sessionData;
+ }
+ public void setSessionData(Map sessionData) {
+ this.sessionData = sessionData;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/basic/UserPermissions.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/basic/UserPermissions.hbm.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/basic/UserPermissions.hbm.xml 2007-08-01
16:19:55 UTC (rev 2808)
@@ -0,0 +1,30 @@
+<?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 is a basic example of how to write a UserCollectionType.
+-->
+
+<hibernate-mapping package="mapping.usercollection.basic">
+
+ <import class="Permission"/>
+
+ <class name="User" table="UC_BSC_USER">
+ <id name="userName"/>
+ <list name="emailAddresses" fetch="join" cascade="all,
delete-orphan"
collection-type="mapping.usercollection.basic.MyListType">
+ <key column="userName"/>
+ <list-index column="displayOrder" base="1"/>
+ <one-to-many class="Email"/>
+ </list>
+ </class>
+
+ <class name="Email">
+ <id name="id">
+ <generator class="native"/>
+ </id>
+ <property name="address"/>
+ </class>
+
+</hibernate-mapping>
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/parameterized/DefaultableList.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/parameterized/DefaultableList.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/parameterized/DefaultableList.java 2007-08-01
16:19:55 UTC (rev 2808)
@@ -0,0 +1,13 @@
+package mapping.usercollection.parameterized;
+
+import java.util.List;
+
+/**
+ * Our specialized collection contract
+ *
+ * @author Holger Brands
+ * @author Steve Ebersole
+ */
+public interface DefaultableList extends List {
+ public String getDefaultValue();
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/parameterized/DefaultableListImpl.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/parameterized/DefaultableListImpl.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/parameterized/DefaultableListImpl.java 2007-08-01
16:19:55 UTC (rev 2808)
@@ -0,0 +1,28 @@
+package mapping.usercollection.parameterized;
+
+import java.util.ArrayList;
+
+/**
+ * Implementation of our specialized collection contract
+ *
+ * @author Holger Brands
+ * @author Steve Ebersole
+ */
+public class DefaultableListImpl extends ArrayList implements DefaultableList {
+ private String defaultValue;
+
+ public DefaultableListImpl() {
+ }
+
+ public DefaultableListImpl(int anticipatedSize) {
+ super( anticipatedSize + ( int ) Math.ceil( anticipatedSize * .75f ) );
+ }
+
+ public String getDefaultValue() {
+ return defaultValue;
+ }
+
+ public void setDefaultValue(String defaultValue) {
+ this.defaultValue = defaultValue;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/parameterized/DefaultableListType.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/parameterized/DefaultableListType.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/parameterized/DefaultableListType.java 2007-08-01
16:19:55 UTC (rev 2808)
@@ -0,0 +1,80 @@
+package mapping.usercollection.parameterized;
+
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+import java.util.List;
+
+import org.hibernate.usertype.UserCollectionType;
+import org.hibernate.usertype.ParameterizedType;
+import org.hibernate.collection.PersistentCollection;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.persister.collection.CollectionPersister;
+import org.hibernate.EntityMode;
+
+/**
+ * Our Hibernate type-system extension for defining our specialized collection
+ * contract.
+ *
+ * @author Holger Brands
+ * @author Steve Ebersole
+ */
+public class DefaultableListType implements UserCollectionType, ParameterizedType {
+ private String defaultValue;
+
+ public Object instantiate(int anticipatedSize) {
+ DefaultableListImpl list = anticipatedSize < 0 ? new DefaultableListImpl() : new
DefaultableListImpl( anticipatedSize );
+ list.setDefaultValue( defaultValue );
+ return list;
+ }
+
+ public PersistentCollection instantiate(
+ SessionImplementor session,
+ CollectionPersister persister) {
+ return new PersistentDefaultableList( session );
+ }
+
+ public PersistentCollection wrap(SessionImplementor session, Object collection) {
+ if ( session.getEntityMode() == EntityMode.DOM4J ) {
+ throw new IllegalStateException( "dom4j not supported" );
+ }
+ else {
+ return new PersistentDefaultableList( session, ( List ) collection );
+ }
+ }
+
+ public Iterator getElementsIterator(Object collection) {
+ return ( ( DefaultableList ) collection ).iterator();
+ }
+
+ public boolean contains(Object collection, Object entity) {
+ return ( ( DefaultableList ) collection ).contains( entity );
+ }
+
+ public Object indexOf(Object collection, Object entity) {
+ int index = ( ( DefaultableList ) collection ).indexOf( entity );
+ return index >= 0 ? new Integer( index ) : null;
+ }
+
+ public Object replaceElements(
+ Object original,
+ Object target,
+ CollectionPersister persister,
+ Object owner,
+ Map copyCache,
+ SessionImplementor session) {
+ DefaultableList result = ( DefaultableList ) target;
+ result.clear();
+ result.addAll( ( DefaultableList ) original );
+ return result;
+ }
+
+ public void setParameterValues(Properties parameters) {
+ defaultValue = parameters.getProperty( "default" );
+ }
+
+ public Object instantiate() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/parameterized/Entity.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/parameterized/Entity.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/parameterized/Entity.java 2007-08-01
16:19:55 UTC (rev 2808)
@@ -0,0 +1,33 @@
+package mapping.usercollection.parameterized;
+
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * Our test entity
+ *
+ * @author Steve Ebersole
+ */
+public class Entity {
+ private String name;
+ private List values = new ArrayList();
+
+ public Entity() {
+ }
+
+ public Entity(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public List getValues() {
+ return values;
+ }
+
+ public void setValues(List values) {
+ this.values = values;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/parameterized/Mapping.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/parameterized/Mapping.hbm.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/parameterized/Mapping.hbm.xml 2007-08-01
16:19:55 UTC (rev 2808)
@@ -0,0 +1,21 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="mapping.usercollection.parameterized"
default-access="field">
+
+ <typedef name="DefaultableList"
class="mapping.usercollection.parameterized.DefaultableListType">
+ <param name="default">Hello</param>
+ </typedef>
+
+ <class name="Entity">
+ <id name="name" type="string"/>
+ <list name="values" fetch="join" table="ENT_VAL"
collection-type="DefaultableList">
+ <key column="ENT_ID"/>
+ <list-index column="POS"/>
+ <element type="string" column="VAL"/>
+ </list>
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/parameterized/PersistentDefaultableList.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/parameterized/PersistentDefaultableList.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/usercollection/parameterized/PersistentDefaultableList.java 2007-08-01
16:19:55 UTC (rev 2808)
@@ -0,0 +1,29 @@
+package mapping.usercollection.parameterized;
+
+import java.util.List;
+
+import org.hibernate.collection.PersistentList;
+import org.hibernate.engine.SessionImplementor;
+
+/**
+ * The "persistent wrapper" around our specialized collection contract
+ *
+ * @author Holger Brands
+ * @author Steve Ebersole
+ */
+public class PersistentDefaultableList extends PersistentList implements DefaultableList
{
+ public PersistentDefaultableList(SessionImplementor session) {
+ super( session );
+ }
+
+ public PersistentDefaultableList(SessionImplementor session, List list) {
+ super( session, list );
+ }
+
+ public PersistentDefaultableList() {
+ }
+
+ public String getDefaultValue() {
+ return ( ( DefaultableList ) this.list ).getDefaultValue();
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/util/dtd/Child.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/util/dtd/Child.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/util/dtd/Child.java 2007-08-01
16:19:55 UTC (rev 2808)
@@ -0,0 +1,36 @@
+package mapping.util.dtd;
+
+/**
+ * The Child class.
+ *
+ * @author Steve Ebersole
+ */
+public class Child {
+ private Long id;
+ private int age;
+ private Parent parent;
+
+ public Child() {
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public Parent getParent() {
+ return parent;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+
+
+ /*package*/ void injectParent(Parent parent) {
+ this.parent = parent;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/util/dtd/Parent.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/util/dtd/Parent.hbm.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/util/dtd/Parent.hbm.xml 2007-08-01
16:19:55 UTC (rev 2808)
@@ -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" [
+ <!ENTITY child SYSTEM
"classpath://org/hibernate/test/util/dtd/child.xml">
+]>
+
+
+<hibernate-mapping package="mapping.util.dtd"
default-access="field">
+
+ <class name="Parent">
+ <id name="id" column="ID">
+ <generator class="increment"/>
+ </id>
+ <list name="children" inverse="true"
cascade="persist,merge">
+ <key column="PRNT_ID" not-null="true"/>
+ <list-index column="SIBLING_ORD"/>
+ <one-to-many class="Child"/>
+ </list>
+ </class>
+
+ &child;
+
+</hibernate-mapping>
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/util/dtd/Parent.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/util/dtd/Parent.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/util/dtd/Parent.java 2007-08-01
16:19:55 UTC (rev 2808)
@@ -0,0 +1,33 @@
+package mapping.util.dtd;
+
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Iterator;
+
+/**
+ * The Parent class.
+ *
+ * @author Steve Ebersole
+ */
+public class Parent {
+ private Long id;
+ private Set children = new HashSet();
+
+ public Long getId() {
+ return id;
+ }
+
+ public Iterator getChildren() {
+ return children.iterator();
+ }
+
+ public Child newChild() {
+ Child child = new Child();
+ child.setAge( 0 );
+
+ child.injectParent( this );
+ this.children.add( child );
+
+ return child;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/util/dtd/child.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/util/dtd/child.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/util/dtd/child.xml 2007-08-01
16:19:55 UTC (rev 2808)
@@ -0,0 +1,9 @@
+
+
+ <class name="Child">
+ <id name="id" column="ID">
+ <generator class="increment"/>
+ </id>
+ <property name="age" column="AGE"
not-null="true"/>
+ <many-to-one name="parent" class="Parent"
column="PRNT_ID"/>
+ </class>
\ No newline at end of file
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/version/db/Group.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/version/db/Group.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/version/db/Group.java 2007-08-01
16:19:55 UTC (rev 2808)
@@ -0,0 +1,56 @@
+// $Id: Group.java 7736 2005-08-03 20:03:34Z steveebersole $
+package mapping.version.db;
+
+import java.util.Date;
+import java.util.Set;
+
+/**
+ * Implementation of Group.
+ *
+ * @author Steve Ebersole
+ */
+public class Group {
+ private Long id;
+ private Date timestamp;
+ private String name;
+ private Set users;
+
+ public Group() {
+ }
+
+ public Group(String name) {
+ this.name = name;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public Date getTimestamp() {
+ return timestamp;
+ }
+
+ public void setTimestamp(Date timestamp) {
+ this.timestamp = timestamp;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Set getUsers() {
+ return users;
+ }
+
+ public void setUsers(Set users) {
+ this.users = users;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/version/db/Permission.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/version/db/Permission.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/version/db/Permission.java 2007-08-01
16:19:55 UTC (rev 2808)
@@ -0,0 +1,66 @@
+// $Id: Permission.java 7736 2005-08-03 20:03:34Z steveebersole $
+package mapping.version.db;
+
+import java.util.Date;
+
+/**
+ * Implementation of Permission.
+ *
+ * @author Steve Ebersole
+ */
+public class Permission {
+ private Long id;
+ private Date timestamp;
+ private String name;
+ private String context;
+ private String access;
+
+ public Permission() {
+ }
+
+ public Permission(String name, String context, String access) {
+ this.name = name;
+ this.context = context;
+ this.access = access;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public Date getTimestamp() {
+ return timestamp;
+ }
+
+ public void setTimestamp(Date timestamp) {
+ this.timestamp = timestamp;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getContext() {
+ return context;
+ }
+
+ public void setContext(String context) {
+ this.context = context;
+ }
+
+ public String getAccess() {
+ return access;
+ }
+
+ public void setAccess(String access) {
+ this.access = access;
+ }
+}
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/version/db/User.hbm.xml
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/version/db/User.hbm.xml
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/version/db/User.hbm.xml 2007-08-01
16:19:55 UTC (rev 2808)
@@ -0,0 +1,55 @@
+<?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.db">
+
+ <class name="User" table="db_vers_user">
+ <id name="id" column="user_id" type="long">
+ <generator class="native"/>
+ </id>
+ <timestamp name="timestamp" column="ts"
source="db"/>
+ <!--<version name="timestamp" column="ts"
type="org.hibernate.type.DbTimestampType"/>-->
+ <property name="username" column="user_name"
type="string" unique="true"/>
+ <set name="groups" table="db_vers_user_group"
batch-size="9" inverse="true" optimistic-lock="true"
lazy="true" cascade="none" >
+ <key column="user_id"/>
+ <many-to-many column="group_id" class="Group"
lazy="false" fetch="join" />
+ </set>
+ <set name="permissions" table="db_vers_user_perm"
batch-size="9" inverse="false" optimistic-lock="false"
lazy="true" cascade="none">
+ <key column="user_id"/>
+ <many-to-many column="perm_id" class="Permission"
lazy="false" fetch="join"/>
+ </set>
+ </class>
+
+ <class name="Group" table="db_vers_group">
+ <id name="id" column="group_id" type="long">
+ <generator class="native"/>
+ </id>
+ <timestamp name="timestamp" column="ts"
source="db"/>
+ <!--<version name="timestamp" column="ts"
type="org.hibernate.type.DbTimestampType"/>-->
+ <property name="name" column="name"
type="string" unique="true"/>
+ <set name="users" table="db_vers_user_group"
batch-size="9" inverse="false" lazy="true"
cascade="none" >
+ <key column="group_id"/>
+ <many-to-many column="user_id" class="User"
lazy="false" fetch="join" />
+ </set>
+ </class>
+
+ <class name="Permission" table="db_vers_permission">
+ <id name="id" column="perm_id" type="long">
+ <generator class="native"/>
+ </id>
+ <timestamp name="timestamp" column="ts"
source="db"/>
+ <!--<version name="timestamp" column="ts"
type="org.hibernate.type.DbTimestampType"/>-->
+ <property name="name" column="name"
type="string" unique="true"/>
+ <property name="context" column="ctx"
type="string"/>
+ <property name="access" column="priv"
type="string"/>
+ </class>
+
+</hibernate-mapping>
Added:
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/version/db/User.java
===================================================================
---
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/version/db/User.java
(rev 0)
+++
trunk/hibernatetools/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/src/mapping/version/db/User.java 2007-08-01
16:19:55 UTC (rev 2808)
@@ -0,0 +1,65 @@
+// $Id: User.java 7736 2005-08-03 20:03:34Z steveebersole $
+package mapping.version.db;
+
+import java.util.Set;
+import java.sql.Timestamp;
+
+/**
+ * Implementation of User.
+ *
+ * @author Steve Ebersole
+ */
+public class User {
+ private Long id;
+ private Timestamp timestamp;
+ private String username;
+ private Set groups;
+ private Set permissions;
+
+ public User() {
+ }
+
+ public User(String username) {
+ this.username = username;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public Timestamp getTimestamp() {
+ return timestamp;
+ }
+
+ public void setTimestamp(Timestamp timestamp) {
+ this.timestamp = timestamp;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public Set getGroups() {
+ return groups;
+ }
+
+ public void setGroups(Set groups) {
+ this.groups = groups;
+ }
+
+ public Set getPermissions() {
+ return permissions;
+ }
+
+ public void setPermissions(Set permissions) {
+ this.permissions = permissions;
+ }
+}