|
From: <hib...@li...> - 2006-06-27 21:25:05
|
Author: ste...@jb...
Date: 2006-06-27 17:25:01 -0400 (Tue, 27 Jun 2006)
New Revision: 10058
Added:
trunk/Hibernate3/test/org/hibernate/test/any/
trunk/Hibernate3/test/org/hibernate/test/any/IntegerPropertyValue.java
trunk/Hibernate3/test/org/hibernate/test/any/Properties.hbm.xml
trunk/Hibernate3/test/org/hibernate/test/any/PropertySet.java
trunk/Hibernate3/test/org/hibernate/test/any/PropertyValue.java
trunk/Hibernate3/test/org/hibernate/test/any/StringPropertyValue.java
Log:
<any/> and <many-to-any/> mappings useful for testing
Added: trunk/Hibernate3/test/org/hibernate/test/any/IntegerPropertyValue.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/any/IntegerPropertyValue.java 2006-06-27 21:22:42 UTC (rev 10057)
+++ trunk/Hibernate3/test/org/hibernate/test/any/IntegerPropertyValue.java 2006-06-27 21:25:01 UTC (rev 10058)
@@ -0,0 +1,38 @@
+package org.hibernate.test.any;
+
+/**
+ * todo: describe IntegerPropertyValue
+ *
+ * @author Steve Ebersole
+ */
+public class IntegerPropertyValue implements PropertyValue {
+ private Long id;
+ private int value;
+
+ public IntegerPropertyValue() {
+ }
+
+ public IntegerPropertyValue(int value) {
+ this.value = value;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public int getValue() {
+ return value;
+ }
+
+ public void setValue(int value) {
+ this.value = value;
+ }
+
+ public String asString() {
+ return Integer.toString( value );
+ }
+}
Added: trunk/Hibernate3/test/org/hibernate/test/any/Properties.hbm.xml
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/any/Properties.hbm.xml 2006-06-27 21:22:42 UTC (rev 10057)
+++ trunk/Hibernate3/test/org/hibernate/test/any/Properties.hbm.xml 2006-06-27 21:25:01 UTC (rev 10058)
@@ -0,0 +1,45 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="org.hibernate.test.any">
+
+ <class name="PropertySet" table="T_PROP_SET">
+ <id name="id" column="ID" type="long">
+ <generator class="increment"/>
+ </id>
+ <property name="name" column="NAME" type="string"/>
+ <any name="someSpecificProperty" id-type="long" meta-type="string" cascade="all">
+ <meta-value value="I" class="IntegerPropertyValue"/>
+ <meta-value value="S" class="StringPropertyValue"/>
+ <column name="S_S_PROP_TYPE"/>
+ <column name="S_S_PROP_ID"/>
+ </any>
+ <map name="generalProperties" table="T_GEN_PROPS" lazy="true" cascade="all">
+ <key column="PROP_SET_ID"/>
+ <map-key type="string" column="GEN_PROP_NAME"/>
+ <many-to-any id-type="long" meta-type="string">
+ <meta-value value="I" class="IntegerPropertyValue"/>
+ <meta-value value="S" class="StringPropertyValue"/>
+ <column name="PROP_TYPE"/>
+ <column name="PROP_ID"/>
+ </many-to-any>
+ </map>
+ </class>
+
+ <class name="StringPropertyValue" table="T_CHAR_PROP">
+ <id name="id" column="ID" type="long">
+ <generator class="increment"/>
+ </id>
+ <property name="value" column="VAL" not-null="true" type="string"/>
+ </class>
+
+ <class name="IntegerPropertyValue" table="T_NUM_PROP">
+ <id name="id" column="ID" type="long">
+ <generator class="increment"/>
+ </id>
+ <property name="value" column="VAL" not-null="true" type="integer"/>
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Added: trunk/Hibernate3/test/org/hibernate/test/any/PropertySet.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/any/PropertySet.java 2006-06-27 21:22:42 UTC (rev 10057)
+++ trunk/Hibernate3/test/org/hibernate/test/any/PropertySet.java 2006-06-27 21:25:01 UTC (rev 10058)
@@ -0,0 +1,55 @@
+package org.hibernate.test.any;
+
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * todo: describe PropertySet
+ *
+ * @author Steve Ebersole
+ */
+public class PropertySet {
+ private Long id;
+ private String name;
+ private PropertyValue someSpecificProperty;
+ private Map generalProperties = new HashMap();
+
+ public PropertySet() {
+ }
+
+ public PropertySet(String name) {
+ this.name = name;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public PropertyValue getSomeSpecificProperty() {
+ return someSpecificProperty;
+ }
+
+ public void setSomeSpecificProperty(PropertyValue someSpecificProperty) {
+ this.someSpecificProperty = someSpecificProperty;
+ }
+
+ public Map getGeneralProperties() {
+ return generalProperties;
+ }
+
+ public void setGeneralProperties(Map generalProperties) {
+ this.generalProperties = generalProperties;
+ }
+}
Added: trunk/Hibernate3/test/org/hibernate/test/any/PropertyValue.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/any/PropertyValue.java 2006-06-27 21:22:42 UTC (rev 10057)
+++ trunk/Hibernate3/test/org/hibernate/test/any/PropertyValue.java 2006-06-27 21:25:01 UTC (rev 10058)
@@ -0,0 +1,10 @@
+package org.hibernate.test.any;
+
+/**
+ * todo: describe PropertyValue
+ *
+ * @author Steve Ebersole
+ */
+public interface PropertyValue {
+ public String asString();
+}
Added: trunk/Hibernate3/test/org/hibernate/test/any/StringPropertyValue.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/any/StringPropertyValue.java 2006-06-27 21:22:42 UTC (rev 10057)
+++ trunk/Hibernate3/test/org/hibernate/test/any/StringPropertyValue.java 2006-06-27 21:25:01 UTC (rev 10058)
@@ -0,0 +1,38 @@
+package org.hibernate.test.any;
+
+/**
+ * todo: describe StringPropertyValue
+ *
+ * @author Steve Ebersole
+ */
+public class StringPropertyValue implements PropertyValue {
+ private Long id;
+ private String value;
+
+ public StringPropertyValue() {
+ }
+
+ public StringPropertyValue(String value) {
+ this.value = value;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public String asString() {
+ return value;
+ }
+}
|