diff options
author | mtaal | 2006-09-07 22:27:42 +0000 |
---|---|---|
committer | mtaal | 2006-09-07 22:27:42 +0000 |
commit | 121875f134c1c5b1f738aa355a03620a6f177e63 (patch) | |
tree | 8e2ef3d5331034e3490731ae4fbddff3538e3269 /plugins | |
parent | 0573e80193efa985ccfdfbe94ef40b44d1402b93 (diff) | |
download | org.eclipse.emf.teneo-121875f134c1c5b1f738aa355a03620a6f177e63.tar.gz org.eclipse.emf.teneo-121875f134c1c5b1f738aa355a03620a6f177e63.tar.xz org.eclipse.emf.teneo-121875f134c1c5b1f738aa355a03620a6f177e63.zip |
Added support for enums
Diffstat (limited to 'plugins')
8 files changed, 321 insertions, 106 deletions
diff --git a/plugins/org.eclipse.emf.teneo.annotations/src/org/eclipse/emf/teneo/annotations/parser/AnnotationParser.java b/plugins/org.eclipse.emf.teneo.annotations/src/org/eclipse/emf/teneo/annotations/parser/AnnotationParser.java index f4e42354e..db32e50a9 100644 --- a/plugins/org.eclipse.emf.teneo.annotations/src/org/eclipse/emf/teneo/annotations/parser/AnnotationParser.java +++ b/plugins/org.eclipse.emf.teneo.annotations/src/org/eclipse/emf/teneo/annotations/parser/AnnotationParser.java @@ -11,7 +11,7 @@ * Martin Taal * </copyright> * - * $Id: AnnotationParser.java,v 1.6 2006/09/05 12:16:57 mtaal Exp $ + * $Id: AnnotationParser.java,v 1.7 2006/09/07 22:27:42 mtaal Exp $ */ package org.eclipse.emf.teneo.annotations.parser; @@ -112,17 +112,31 @@ public class AnnotationParser { case AnnotationTokenizer.T_IDENTIFIER: final String identifier = annotationTokenizer.getLexeme(); // next token must be an is - if (annotationTokenizer.nextToken() != AnnotationTokenizer.T_IS) { + int nextToken = annotationTokenizer.nextToken(); + if (nextToken == AnnotationTokenizer.T_CONTENTEND) { + final PrimitiveValueNode vn = new PrimitiveValueNode(); + vn.setName("value"); + vn.setValue(identifier); + addToParent(pn, vn); + return; + } + if (nextToken != AnnotationTokenizer.T_IS) { throw new AnnotationParserException("No = character after identifier, see _ for error position " + annotationTokenizer.getErrorText()); } - final int nextToken = annotationTokenizer.nextToken(); + nextToken = annotationTokenizer.nextToken(); if (nextToken == AnnotationTokenizer.T_VALUE) { final String value = annotationTokenizer.getLexeme(); final PrimitiveValueNode vn = new PrimitiveValueNode(); vn.setName(identifier); vn.setValue(value); addToParent(pn, vn); + }if (nextToken == AnnotationTokenizer.T_VALUE) { + final String value = annotationTokenizer.getLexeme(); + final PrimitiveValueNode vn = new PrimitiveValueNode(); + vn.setName(identifier); + vn.setValue(value); + addToParent(pn, vn); } else if (nextToken == AnnotationTokenizer.T_IDENTIFIER) { final String value = annotationTokenizer.getLexeme(); final PrimitiveValueNode vn = new PrimitiveValueNode(); diff --git a/plugins/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapper/AbstractPropertyMapper.java b/plugins/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapper/AbstractPropertyMapper.java index 78a83d985..f344f8a29 100644 --- a/plugins/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapper/AbstractPropertyMapper.java +++ b/plugins/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapper/AbstractPropertyMapper.java @@ -12,7 +12,7 @@ * Davide Marchignoli * </copyright> * - * $Id: AbstractPropertyMapper.java,v 1.1 2006/07/05 22:29:30 mtaal Exp $ + * $Id: AbstractPropertyMapper.java,v 1.2 2006/09/07 22:27:50 mtaal Exp $ */ package org.eclipse.emf.teneo.hibernate.mapper; @@ -81,4 +81,14 @@ class AbstractPropertyMapper extends AbstractMapper { return typeName; } + /** Returns the correct enum primitive hibernate type, for Elver this is a hibernate user type. */ + protected String hbDynamicEnumType(Enumerated enumerated) { + final String typeName; + if (EnumType.STRING == enumerated.getValue().getValue()) { + typeName = "org.eclipse.emf.teneo.hibernate.mapping.DynamicENumUserType"; + } else { + typeName = "org.eclipse.emf.teneo.hibernate.mapping.DynamicENumUserIntegerType"; + } + return typeName; + } } diff --git a/plugins/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapper/BasicMapper.java b/plugins/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapper/BasicMapper.java index 4580f2e9c..53516e3b4 100644 --- a/plugins/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapper/BasicMapper.java +++ b/plugins/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapper/BasicMapper.java @@ -12,7 +12,7 @@ * Davide Marchignoli * </copyright> * - * $Id: BasicMapper.java,v 1.4 2006/09/06 17:26:44 mtaal Exp $ + * $Id: BasicMapper.java,v 1.5 2006/09/07 22:27:50 mtaal Exp $ */ package org.eclipse.emf.teneo.hibernate.mapper; @@ -24,6 +24,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.eclipse.emf.ecore.EAttribute; import org.eclipse.emf.ecore.EDataType; +import org.eclipse.emf.ecore.EEnum; import org.eclipse.emf.teneo.annotations.pamodel.PAnnotatedEAttribute; import org.eclipse.emf.teneo.annotations.pamodel.PAnnotatedEStructuralFeature; import org.eclipse.emf.teneo.annotations.pannotation.Basic; @@ -40,6 +41,8 @@ import org.eclipse.emf.teneo.annotations.processing.TransientProcessor; import org.eclipse.emf.teneo.annotations.processing.VersionProcessor; import org.eclipse.emf.teneo.annotations.util.EcoreDataTypes; import org.eclipse.emf.teneo.hibernate.hbmodel.HbAnnotatedEAttribute; +import org.eclipse.emf.teneo.hibernate.mapping.DynamicENumUserType; +import org.eclipse.emf.teneo.hibernate.mapping.ENumUserType; import org.eclipse.emf.teneo.simpledom.Element; /** @@ -223,17 +226,22 @@ class BasicMapper extends AbstractPropertyMapper implements BasicProcessor, Tran propElement.addAttribute("lazy", FetchType.LAZY_LITERAL.equals(basic.getFetch()) ? "true" : "false"); propElement.addAttribute("access", "org.eclipse.emf.teneo.hibernate.mapping.EFeatureAccessor"); addColumn(propElement, eattr.getName(), column, getHbmContext().isCurrentElementFeatureMap(), false); - - final String instanceClassName; + if (paAttribute.getAnnotatedEAttribute().getEType().getInstanceClass() != null) { - instanceClassName = eattr.getEType().getInstanceClass().getName(); + propElement.addElement("type"). + addAttribute("name", hbEnumType(enumerated)). + addElement("param"). + addAttribute("name", ENumUserType.ENUM_CLASS_PARAM). + addText(eattr.getEType().getInstanceClass().getName()); } else { - instanceClassName = eattr.getEType().getInstanceClassName(); + final Element typeElement = propElement.addElement("type"). + addAttribute("name", hbDynamicEnumType(enumerated)); + typeElement.addElement("param").addAttribute("name", DynamicENumUserType.ECLASSIFIER_PARAM). + addText(paAttribute.getAnnotatedEAttribute().getEType().getName()); + typeElement.addElement("param").addAttribute("name", DynamicENumUserType.EPACKAGE_PARAM). + addText(paAttribute.getAnnotatedEAttribute().getEType().getEPackage().getNsURI()); } - propElement.addElement("type").addAttribute("name", hbEnumType(enumerated)).addElement("param").addAttribute( - "name", "enumClass").addText(instanceClassName); - addIsSetAttribute(paAttribute); propElement.addAttribute("not-null", isNullable(basic, eattr) ? "false" : "true"); propElement.addAttribute("unique", eattr.isUnique() ? "true" : "false"); diff --git a/plugins/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapper/IdMapper.java b/plugins/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapper/IdMapper.java index 639d9ab51..d63a91716 100644 --- a/plugins/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapper/IdMapper.java +++ b/plugins/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapper/IdMapper.java @@ -12,7 +12,7 @@ * Davide Marchignoli * </copyright> * - * $Id: IdMapper.java,v 1.6 2006/09/04 15:42:32 mtaal Exp $ + * $Id: IdMapper.java,v 1.7 2006/09/07 22:27:50 mtaal Exp $ */ package org.eclipse.emf.teneo.hibernate.mapper; @@ -39,6 +39,8 @@ import org.eclipse.emf.teneo.annotations.processing.ProcessingException; import org.eclipse.emf.teneo.hibernate.hbannotation.GenericGenerator; import org.eclipse.emf.teneo.hibernate.hbannotation.Parameter; import org.eclipse.emf.teneo.hibernate.hbmodel.HbAnnotatedEPackage; +import org.eclipse.emf.teneo.hibernate.mapping.DynamicENumUserType; +import org.eclipse.emf.teneo.hibernate.mapping.ENumUserType; import org.eclipse.emf.teneo.simpledom.DocumentHelper; import org.eclipse.emf.teneo.simpledom.Element; @@ -204,9 +206,20 @@ class IdMapper extends AbstractPropertyMapper implements IdProcessor { if (id.getEnumerated() == null) { usedIdElement.addAttribute("type", AbstractPropertyMapper.hbType(eAttribute.getEAttributeType())); } else { // enumerated id - usedIdElement.addElement("type").addAttribute("name", hbEnumType(id.getEnumerated())).addElement("param") - .addAttribute("name", "enumClass").addText( - id.getAnnotatedEAttribute().getEType().getInstanceClassName()); + if (id.getAnnotatedEAttribute().getEType().getInstanceClass() != null) { + usedIdElement.addElement("type"). + addAttribute("name", hbEnumType(id.getEnumerated())). + addElement("param"). + addAttribute("name", ENumUserType.ENUM_CLASS_PARAM). + addText(eAttribute.getEType().getInstanceClass().getName()); + } else { + final Element typeElement = usedIdElement.addElement("type"). + addAttribute("name", hbDynamicEnumType(id.getEnumerated())); + typeElement.addElement("param").addAttribute("name", DynamicENumUserType.ECLASSIFIER_PARAM). + addText(id.getAnnotatedEAttribute().getEType().getName()); + typeElement.addElement("param").addAttribute("name", DynamicENumUserType.EPACKAGE_PARAM). + addText(id.getAnnotatedEAttribute().getEType().getEPackage().getNsURI()); + } } addColumn(usedIdElement, eAttribute.getName(), column, false, true); diff --git a/plugins/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/DynamicENumUserIntegerType.java b/plugins/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/DynamicENumUserIntegerType.java new file mode 100644 index 000000000..53be29f2d --- /dev/null +++ b/plugins/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/DynamicENumUserIntegerType.java @@ -0,0 +1,82 @@ +/** + * <copyright> + * + * Copyright (c) 2005, 2006 Springsite BV (The Netherlands) and others + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Taal + * </copyright> + * + * $Id: DynamicENumUserIntegerType.java,v 1.1 2006/09/07 22:27:50 mtaal Exp $ + */ + +package org.eclipse.emf.teneo.hibernate.mapping; + +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Types; +import java.util.HashMap; + +import org.eclipse.emf.common.util.AbstractEnumerator; +import org.eclipse.emf.common.util.Enumerator; +import org.eclipse.emf.ecore.EEnumLiteral; +import org.hibernate.HibernateException; + +/** + * Implements the EMF UserType for an Enum in a dynamic model, for an integer field. + * + * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> + * @version $Revision: 1.1 $ $Date: 2006/09/07 22:27:50 $ + */ + +public class DynamicENumUserIntegerType extends DynamicENumUserType { + + /** The sql types used for enums */ + private static final int[] SQL_TYPES = new int[] { Types.INTEGER }; + + /** Hashmap with string to enum mappings */ + private final HashMap localCache = new HashMap(); + + /* + * (non-Javadoc) + * + * @see org.hibernate.usertype.UserType#nullSafeGet(java.sql.ResultSet, java.lang.String[], java.lang.Object) + */ + public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException { + final int value = rs.getInt(names[0]); + if (rs.wasNull()) + return null; + + Integer objValue = new Integer(value); + Enumerator enumValue = (Enumerator) localCache.get(objValue); + if (enumValue != null) + return enumValue; + + enumValue = enumInstance.getEEnumLiteral(objValue.intValue()); + localCache.put(objValue, enumValue); + return enumValue; + } + + /* + * (non-Javadoc) + * + * @see org.hibernate.usertype.UserType#nullSafeSet(java.sql.PreparedStatement, java.lang.Object, int) + */ + public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException { + if (value == null) { + st.setNull(index, Types.INTEGER); + } else { + st.setInt(index, ((EEnumLiteral) value).getValue()); + } + } + + /** An enum is stored in one varchar */ + public int[] sqlTypes() { + return SQL_TYPES; + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/DynamicENumUserType.java b/plugins/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/DynamicENumUserType.java new file mode 100644 index 000000000..2e7e650f4 --- /dev/null +++ b/plugins/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/DynamicENumUserType.java @@ -0,0 +1,170 @@ +/** + * <copyright> + * + * Copyright (c) 2005, 2006 Springsite BV (The Netherlands) and others + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Taal + * </copyright> + * + * $Id: DynamicENumUserType.java,v 1.1 2006/09/07 22:27:50 mtaal Exp $ + */ + +package org.eclipse.emf.teneo.hibernate.mapping; + +import java.io.Serializable; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Types; +import java.util.HashMap; +import java.util.Properties; + +import org.eclipse.emf.common.util.Enumerator; +import org.eclipse.emf.ecore.EEnum; +import org.eclipse.emf.ecore.EEnumLiteral; +import org.eclipse.emf.ecore.EPackage; +import org.hibernate.HibernateException; +import org.hibernate.usertype.ParameterizedType; +import org.hibernate.usertype.UserType; + +/** + * Implements the EMF UserType for an Enum + * + * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> + * @version $Revision: 1.1 $ $Date: 2006/09/07 22:27:50 $ + */ + +public class DynamicENumUserType implements UserType, ParameterizedType { + /** The expected parameter name which contains the enum class name */ + public static final String EPACKAGE_PARAM = "epackage"; + public static final String ECLASSIFIER_PARAM = "eclassifier"; + + /** The sql types used for enums */ + private static final int[] SQL_TYPES = new int[] { Types.VARCHAR }; + + /** The enum type we are handling here */ + protected EEnum enumInstance; + + /** Hashmap with string to enum mappings */ + private final HashMap localCache = new HashMap(); + + /* + * (non-Javadoc) + * + * @see org.hibernate.usertype.UserType#assemble(java.io.Serializable, java.lang.Object) + */ + public Object assemble(Serializable cached, Object owner) throws HibernateException { + return cached; + } + + /* + * (non-Javadoc) + * + * @see org.hibernate.usertype.UserType#deepCopy(java.lang.Object) + */ + public Object deepCopy(Object value) throws HibernateException { + return value; + } + + /* + * (non-Javadoc) + * + * @see org.hibernate.usertype.UserType#disassemble(java.lang.Object) + */ + public Serializable disassemble(Object value) throws HibernateException { + return (Serializable) value; + } + + /** Compares the int values of the enumerates */ + public boolean equals(Object x, Object y) throws HibernateException { + // todo: check compare on null values + if (x == null && y == null) + return true; + + if (x == null || y == null) + return false; + + if (x.getClass() != y.getClass()) + return false; + assert (x instanceof EEnumLiteral); + return ((EEnumLiteral) x).getValue() == ((EEnumLiteral) y).getValue(); + } + + /* + * (non-Javadoc) + * + * @see org.hibernate.usertype.UserType#hashCode(java.lang.Object) + */ + public int hashCode(Object x) throws HibernateException { + return x.hashCode(); + } + + /** Not mutable */ + public boolean isMutable() { + return false; + } + + /* + * (non-Javadoc) + * + * @see org.hibernate.usertype.UserType#nullSafeGet(java.sql.ResultSet, java.lang.String[], java.lang.Object) + */ + public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException { + final String name = rs.getString(names[0]); + if (rs.wasNull()) + return null; + + Enumerator enumValue = (Enumerator) localCache.get(name); + if (enumValue != null) + return enumValue; + + enumValue = enumInstance.getEEnumLiteralByLiteral(name); + localCache.put(name, enumValue); + return enumValue; + } + + /* + * (non-Javadoc) + * + * @see org.hibernate.usertype.UserType#nullSafeSet(java.sql.PreparedStatement, java.lang.Object, int) + */ + public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException { + if (value == null) { + st.setNull(index, Types.VARCHAR); + } else { + st.setString(index, ((EEnumLiteral) value).getName()); + } + } + + /* + * (non-Javadoc) + * + * @see org.hibernate.usertype.UserType#replace(java.lang.Object, java.lang.Object, java.lang.Object) + */ + public Object replace(Object original, Object target, Object owner) throws HibernateException { + return original; + } + + /** Returns the parameterizezd enumType */ + public Class returnedClass() { + return enumInstance.getClass(); + } + + /** An enum is stored in one varchar */ + public int[] sqlTypes() { + return SQL_TYPES; + } + + /** Sets the enumclass */ + public void setParameterValues(Properties parameters) { + final String epackUri = parameters.getProperty(EPACKAGE_PARAM); + final String eclassifier = parameters.getProperty(ECLASSIFIER_PARAM); + final EPackage epack = EPackage.Registry.INSTANCE.getEPackage(epackUri); + enumInstance = (EEnum)epack.getEClassifier(eclassifier); + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/ENumUserIntegerType.java b/plugins/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/ENumUserIntegerType.java index be15ebc58..15ddf7546 100644 --- a/plugins/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/ENumUserIntegerType.java +++ b/plugins/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/ENumUserIntegerType.java @@ -11,13 +11,11 @@ * Martin Taal * </copyright> * - * $Id: ENumUserIntegerType.java,v 1.1 2006/07/05 22:29:31 mtaal Exp $ + * $Id: ENumUserIntegerType.java,v 1.2 2006/09/07 22:27:50 mtaal Exp $ */ package org.eclipse.emf.teneo.hibernate.mapping; -import java.io.Serializable; -import java.lang.reflect.Method; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; @@ -31,91 +29,25 @@ import org.eclipse.emf.teneo.classloader.ClassLoaderResolver; import org.eclipse.emf.teneo.classloader.StoreClassLoadException; import org.eclipse.emf.teneo.hibernate.HbStoreException; import org.hibernate.HibernateException; -import org.hibernate.usertype.ParameterizedType; -import org.hibernate.usertype.UserType; /** - * Implements the EMF UserType for an Enum + * Implements the EMF UserType for an Enum where the value is stored as an int. * * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> - * @version $Revision: 1.1 $ $Date: 2006/07/05 22:29:31 $ + * @version $Revision: 1.2 $ $Date: 2006/09/07 22:27:50 $ */ -public class ENumUserIntegerType implements UserType, ParameterizedType { - /** The expected parameter name which contains the enum class name */ - public static final String ENUM_CLASS_PARAM = "enumClass"; +public class ENumUserIntegerType extends ENumUserType { /** The sql types used for enums */ private static final int[] SQL_TYPES = new int[] { Types.INTEGER }; - /** The enum type we are handling here */ - private Class enumType; - - /** The method which translates a string to an instance of the emf enum */ - private Method getMethod; - /** Hashmap with string to enum mappings */ private final HashMap localCache = new HashMap(); /* * (non-Javadoc) * - * @see org.hibernate.usertype.UserType#assemble(java.io.Serializable, java.lang.Object) - */ - public Object assemble(Serializable cached, Object owner) throws HibernateException { - return cached; - } - - /* - * (non-Javadoc) - * - * @see org.hibernate.usertype.UserType#deepCopy(java.lang.Object) - */ - public Object deepCopy(Object value) throws HibernateException { - return value; - } - - /* - * (non-Javadoc) - * - * @see org.hibernate.usertype.UserType#disassemble(java.lang.Object) - */ - public Serializable disassemble(Object value) throws HibernateException { - return (Serializable) value; - } - - /** Compares the int values of the enumerates */ - public boolean equals(Object x, Object y) throws HibernateException { - // todo: check compare on null values - if (x == null && y == null) - return true; - - if (x == null || y == null) - return false; - - if (x.getClass() != y.getClass()) - return false; - assert (x instanceof AbstractEnumerator); - return ((AbstractEnumerator) x).getValue() == ((AbstractEnumerator) y).getValue(); - } - - /* - * (non-Javadoc) - * - * @see org.hibernate.usertype.UserType#hashCode(java.lang.Object) - */ - public int hashCode(Object x) throws HibernateException { - return x.hashCode(); - } - - /** Not mutable */ - public boolean isMutable() { - return false; - } - - /* - * (non-Javadoc) - * * @see org.hibernate.usertype.UserType#nullSafeGet(java.sql.ResultSet, java.lang.String[], java.lang.Object) */ public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException { @@ -153,20 +85,6 @@ public class ENumUserIntegerType implements UserType, ParameterizedType { } } - /* - * (non-Javadoc) - * - * @see org.hibernate.usertype.UserType#replace(java.lang.Object, java.lang.Object, java.lang.Object) - */ - public Object replace(Object original, Object target, Object owner) throws HibernateException { - return original; - } - - /** Returns the parameterizezd enumType */ - public Class returnedClass() { - return enumType; - } - /** An enum is stored in one varchar */ public int[] sqlTypes() { return SQL_TYPES; diff --git a/plugins/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/ENumUserType.java b/plugins/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/ENumUserType.java index 3e2c711fb..76e46f8e8 100644 --- a/plugins/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/ENumUserType.java +++ b/plugins/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/ENumUserType.java @@ -11,7 +11,7 @@ * Martin Taal * </copyright> * - * $Id: ENumUserType.java,v 1.1 2006/07/05 22:29:31 mtaal Exp $ + * $Id: ENumUserType.java,v 1.2 2006/09/07 22:27:50 mtaal Exp $ */ package org.eclipse.emf.teneo.hibernate.mapping; @@ -38,7 +38,7 @@ import org.hibernate.usertype.UserType; * Implements the EMF UserType for an Enum * * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> - * @version $Revision: 1.1 $ $Date: 2006/07/05 22:29:31 $ + * @version $Revision: 1.2 $ $Date: 2006/09/07 22:27:50 $ */ public class ENumUserType implements UserType, ParameterizedType { @@ -49,10 +49,10 @@ public class ENumUserType implements UserType, ParameterizedType { private static final int[] SQL_TYPES = new int[] { Types.VARCHAR }; /** The enum type we are handling here */ - private Class enumType; + protected Class enumType; /** The method which translates a string to an instance of the emf enum */ - private Method getMethod; + protected Method getMethod; /** Hashmap with string to enum mappings */ private final HashMap localCache = new HashMap(); |