diff options
Diffstat (limited to 'hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping')
69 files changed, 1132 insertions, 1474 deletions
diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/AnyEObjectType.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/AnyEObjectType.java index eb7c2ce7e..a32a241fa 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/AnyEObjectType.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/AnyEObjectType.java @@ -48,24 +48,21 @@ import org.hibernate.type.StandardBasicTypes; import org.hibernate.type.Type; /** - * Supports persisting the reference to any persistable EObect, it stores the - * entity name, and the id in a string field + * Supports persisting the reference to any persistable EObect, it stores the entity name, and the + * id in a string field * * @author <a href="mailto:mkanaley@tibco.com">Mike Kanaley</a> */ -public class AnyEObjectType extends AbstractType implements CompositeType, - AssociationType { +public class AnyEObjectType extends AbstractType implements CompositeType, AssociationType { /** * Generated Serial ID */ private static final long serialVersionUID = 3857353606004705457L; - private static final String[] PROPERTY_NAMES = new String[] { "class", - "idtype", "idstr" }; + private static final String[] PROPERTY_NAMES = new String[] { "class", "idtype", "idstr" }; - private static final int[] SQL_TYPES = { Types.VARCHAR, Types.VARCHAR, - Types.VARCHAR }; + private static final int[] SQL_TYPES = { Types.VARCHAR, Types.VARCHAR, Types.VARCHAR }; /** Constructor by id */ private final HashMap<String, Constructor<?>> constructors = new HashMap<String, Constructor<?>>(); @@ -80,8 +77,8 @@ public class AnyEObjectType extends AbstractType implements CompositeType, } /** Just returns the value */ - public Object deepCopy(Object value, EntityMode entityMode, - SessionFactoryImplementor factory) throws HibernateException { + public Object deepCopy(Object value, EntityMode entityMode, SessionFactoryImplementor factory) + throws HibernateException { return value; } @@ -91,8 +88,7 @@ public class AnyEObjectType extends AbstractType implements CompositeType, } /** Checks using equals */ - public boolean isSame(Object x, Object y, EntityMode entityMode) - throws HibernateException { + public boolean isSame(Object x, Object y, EntityMode entityMode) throws HibernateException { if (x != null) { return x.equals(y); } @@ -100,7 +96,7 @@ public class AnyEObjectType extends AbstractType implements CompositeType, } /** Compare is not implemented, returning 0 for now */ - + public int compare(Object x, Object y, EntityMode entityMode) { return 0; } @@ -121,15 +117,13 @@ public class AnyEObjectType extends AbstractType implements CompositeType, } /** Returns unsupportedexception */ - public Object nullSafeGet(ResultSet rs, String name, - SessionImplementor session, Object owner) + public Object nullSafeGet(ResultSet rs, String name, SessionImplementor session, Object owner) throws HibernateException, SQLException { throw new UnsupportedOperationException("Type is a multicolumn type"); } /** Returns the object from the resultset */ - public Object nullSafeGet(ResultSet rs, String[] names, - SessionImplementor session, Object owner) + public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException { final String entityName = rs.getString(names[0]); if (rs.wasNull()) { @@ -144,8 +138,7 @@ public class AnyEObjectType extends AbstractType implements CompositeType, return null; } - return session.internalLoad(entityName, getId(idStr, idType), true, - false); + return session.internalLoad(entityName, getId(idStr, idType), true, false); } /** Creates an id object of the correct type */ @@ -153,23 +146,17 @@ public class AnyEObjectType extends AbstractType implements CompositeType, try { Constructor<?> constructor = constructors.get(idType); if (constructor == null) { - final Class<?> idClass = this.getClass().getClassLoader() - .loadClass(idType); - constructor = idClass - .getConstructor(new Class[] { String.class }); + final Class<?> idClass = this.getClass().getClassLoader().loadClass(idType); + constructor = idClass.getConstructor(new Class[] { String.class }); constructors.put(idType, constructor); } - return (Serializable) constructor - .newInstance(new Object[] { idStr }); + return (Serializable) constructor.newInstance(new Object[] { idStr }); } catch (Exception e) { - throw new HbStoreException("Could not create id type for " + idType - + " and id " + idStr, e); + throw new HbStoreException("Could not create id type for " + idType + " and id " + idStr, e); } } - - public Object hydrate(ResultSet rs, String[] names, - SessionImplementor session, Object owner) + public Object hydrate(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException { final String entityName = rs.getString(names[0]); if (rs.wasNull()) { @@ -187,7 +174,6 @@ public class AnyEObjectType extends AbstractType implements CompositeType, return new EObjectCacheEntry(entityName, getId(idStr, idType)); } - public Object resolve(Object value, SessionImplementor session, Object owner) throws HibernateException { EObjectCacheEntry entry = (EObjectCacheEntry) value; @@ -195,28 +181,25 @@ public class AnyEObjectType extends AbstractType implements CompositeType, } /* - * public Object semiResolve(Object value, SessionImplementor session, - * Object owner) throws HibernateException { throw new - * UnsupportedOperationException("Any mappings may not form part of a - * property-ref"); } + * public Object semiResolve(Object value, SessionImplementor session, Object owner) throws + * HibernateException { throw new UnsupportedOperationException("Any mappings may not form part of + * a property-ref"); } */ - public void nullSafeSet(PreparedStatement st, Object value, int index, - SessionImplementor session) throws HibernateException, SQLException { + public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) + throws HibernateException, SQLException { nullSafeSet(st, value, index, null, session); } - public void nullSafeSet(PreparedStatement st, Object value, int index, - boolean[] settable, SessionImplementor session) - throws HibernateException, SQLException { + public void nullSafeSet(PreparedStatement st, Object value, int index, boolean[] settable, + SessionImplementor session) throws HibernateException, SQLException { String entityName = null; String idStr = null; String idType = null; if (value != null) { entityName = session.bestGuessEntityName(value); - Serializable id = ForeignKeys.getEntityIdentifierIfNotUnsaved( - entityName, value, session); + Serializable id = ForeignKeys.getEntityIdentifierIfNotUnsaved(entityName, value, session); idType = id.getClass().getName(); idStr = id.toString(); st.setString(index, entityName); @@ -238,19 +221,16 @@ public class AnyEObjectType extends AbstractType implements CompositeType, return SQL_TYPES; } - public void setToXMLNode(Node xml, Object value, - SessionFactoryImplementor factory) { - throw new UnsupportedOperationException( - "Any types cannot be stringified"); + public void setToXMLNode(Node xml, Object value, SessionFactoryImplementor factory) { + throw new UnsupportedOperationException("Any types cannot be stringified"); } - public String toLoggableString(Object value, - SessionFactoryImplementor factory) throws HibernateException { + public String toLoggableString(Object value, SessionFactoryImplementor factory) + throws HibernateException { return value == null ? "null" : value.getClass().getName(); } - public Object fromXMLNode(Node xml, Mapping factory) - throws HibernateException { + public Object fromXMLNode(Node xml, Mapping factory) throws HibernateException { throw new UnsupportedOperationException(); // TODO: is this right?? } @@ -272,42 +252,35 @@ public class AnyEObjectType extends AbstractType implements CompositeType, } } - - public Object assemble(Serializable cached, SessionImplementor session, - Object owner) throws HibernateException { + public Object assemble(Serializable cached, SessionImplementor session, Object owner) + throws HibernateException { final EObjectCacheEntry entry = (EObjectCacheEntry) cached; - return entry == null ? null : session.internalLoad(entry.entityName, - entry.id, true, false); + return entry == null ? null : session.internalLoad(entry.entityName, entry.id, true, false); } - - public Serializable disassemble(Object value, SessionImplementor session, - Object owner) throws HibernateException { + public Serializable disassemble(Object value, SessionImplementor session, Object owner) + throws HibernateException { if (value == null) { return null; } final String entityName = session.bestGuessEntityName(value); - final Serializable id = ForeignKeys.getEntityIdentifierIfNotUnsaved( - entityName, value, session); + final Serializable id = ForeignKeys.getEntityIdentifierIfNotUnsaved(entityName, value, session); return new EObjectCacheEntry(entityName, id); } - public boolean isAnyType() { return true; } @SuppressWarnings("rawtypes") - public Object replace(Object original, Object target, - SessionImplementor session, Object owner, Map copyCache) - throws HibernateException { + public Object replace(Object original, Object target, SessionImplementor session, Object owner, + Map copyCache) throws HibernateException { if (original == null) { return null; } else { final String entityName = session.bestGuessEntityName(original); - final Serializable id = ForeignKeys - .getEntityIdentifierIfNotUnsaved(entityName, original, - session); + final Serializable id = ForeignKeys.getEntityIdentifierIfNotUnsaved(entityName, original, + session); return session.internalLoad(entityName, id, true, false); } } @@ -324,12 +297,11 @@ public class AnyEObjectType extends AbstractType implements CompositeType, return PROPERTY_NAMES; } - public Object getPropertyValue(Object component, int i, - SessionImplementor session) throws HibernateException { + public Object getPropertyValue(Object component, int i, SessionImplementor session) + throws HibernateException { if (component != null) { final String entityName = session.bestGuessEntityName(component); - Serializable id = ForeignKeys.getEntityIdentifierIfNotUnsaved( - entityName, component, session); + Serializable id = ForeignKeys.getEntityIdentifierIfNotUnsaved(entityName, component, session); switch (i) { case 0: return session.bestGuessEntityName(component); @@ -344,25 +316,24 @@ public class AnyEObjectType extends AbstractType implements CompositeType, return null; } - public Object[] getPropertyValues(Object component, - SessionImplementor session) throws HibernateException { + public Object[] getPropertyValues(Object component, SessionImplementor session) + throws HibernateException { if (component != null) { final String entityName = session.bestGuessEntityName(component); - Serializable id = ForeignKeys.getEntityIdentifierIfNotUnsaved( - entityName, component, session); - return new Object[] { session.bestGuessEntityName(component), - id.getClass().getName(), id.toString() }; + Serializable id = ForeignKeys.getEntityIdentifierIfNotUnsaved(entityName, component, session); + return new Object[] { session.bestGuessEntityName(component), id.getClass().getName(), + id.toString() }; } return null; } public Type[] getSubtypes() { - return new Type[] { StandardBasicTypes.STRING, - StandardBasicTypes.STRING, StandardBasicTypes.STRING }; + return new Type[] { StandardBasicTypes.STRING, StandardBasicTypes.STRING, + StandardBasicTypes.STRING }; } - public void setPropertyValues(Object component, Object[] values, - EntityMode entityMode) throws HibernateException { + public void setPropertyValues(Object component, Object[] values, EntityMode entityMode) + throws HibernateException { throw new UnsupportedOperationException(); } @@ -370,7 +341,6 @@ public class AnyEObjectType extends AbstractType implements CompositeType, throw new UnsupportedOperationException(); } - public boolean isComponentType() { return true; } @@ -379,7 +349,6 @@ public class AnyEObjectType extends AbstractType implements CompositeType, return ForeignKeyDirection.FOREIGN_KEY_FROM_PARENT; } - public boolean isAssociationType() { return true; } @@ -389,11 +358,9 @@ public class AnyEObjectType extends AbstractType implements CompositeType, } public Joinable getAssociatedJoinable(SessionFactoryImplementor factory) { - throw new UnsupportedOperationException( - "any types do not have a unique referenced persister"); + throw new UnsupportedOperationException("any types do not have a unique referenced persister"); } - public boolean isModified(Object old, Object current, boolean[] checkable, SessionImplementor session) throws HibernateException { if (current == null) { @@ -405,8 +372,8 @@ public class AnyEObjectType extends AbstractType implements CompositeType, final EObjectCacheEntry entry = (EObjectCacheEntry) old; final String entityName = session.bestGuessEntityName(current); - final Serializable id = ForeignKeys.getEntityIdentifierIfNotUnsaved( - entityName, current, session); + final Serializable id = ForeignKeys.getEntityIdentifierIfNotUnsaved(entityName, current, + session); if (checkable[0] && entry.entityName.compareTo(entityName) != 0) { return true; } @@ -416,10 +383,8 @@ public class AnyEObjectType extends AbstractType implements CompositeType, return false; } - public String getAssociatedEntityName(SessionFactoryImplementor factory) - throws MappingException { - throw new UnsupportedOperationException( - "any types do not have a unique referenced persister"); + public String getAssociatedEntityName(SessionFactoryImplementor factory) throws MappingException { + throw new UnsupportedOperationException("any types do not have a unique referenced persister"); } public boolean[] getPropertyNullability() { @@ -427,8 +392,7 @@ public class AnyEObjectType extends AbstractType implements CompositeType, } @SuppressWarnings("rawtypes") - public String getOnCondition(String alias, - SessionFactoryImplementor factory, Map enabledFilters) + public String getOnCondition(String alias, SessionFactoryImplementor factory, Map enabledFilters) throws MappingException { throw new UnsupportedOperationException(); } @@ -461,8 +425,8 @@ public class AnyEObjectType extends AbstractType implements CompositeType, return result; } - public boolean isDirty(Object old, Object current, boolean[] checkable, - SessionImplementor session) throws HibernateException { + public boolean isDirty(Object old, Object current, boolean[] checkable, SessionImplementor session) + throws HibernateException { return isDirty(old, current, session); } @@ -471,15 +435,14 @@ public class AnyEObjectType extends AbstractType implements CompositeType, } public Size[] dictatedSizes(Mapping mapping) throws MappingException { - return new Size[]{new Size(), new Size(), new Size()}; + return new Size[] { new Size(), new Size(), new Size() }; } public Size[] defaultSizes(Mapping mapping) throws MappingException { - return new Size[]{new Size(), new Size(), new Size()}; + return new Size[] { new Size(), new Size(), new Size() }; } - public Object deepCopy(Object value, SessionFactoryImplementor factory) - throws HibernateException { + public Object deepCopy(Object value, SessionFactoryImplementor factory) throws HibernateException { // TODO Auto-generated method stub return value; } diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/DefaultToStringUserType.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/DefaultToStringUserType.java index 7fffdfa05..9b137ee97 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/DefaultToStringUserType.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/DefaultToStringUserType.java @@ -33,9 +33,9 @@ import org.hibernate.usertype.ParameterizedType; import org.hibernate.usertype.UserType; /** - * Provides a Hibernate extension (called a UserType) to support serializing EMF custom datatypes into VARCHAR columns. - * The custom DataType mappers provided by this plugin have the job of registering Hibernate typedefs that use this - * UserType implementation. + * Provides a Hibernate extension (called a UserType) to support serializing EMF custom datatypes + * into VARCHAR columns. The custom DataType mappers provided by this plugin have the job of + * registering Hibernate typedefs that use this UserType implementation. * * This class is intended for contribution to Teneo. * @@ -84,7 +84,7 @@ public class DefaultToStringUserType implements UserType, ParameterizedType { * Provide a copy of the datatypes. Converts to String and then back to datatype again. * * @param value - * the value to copy. + * the value to copy. * @return the value always. */ public Object deepCopy(Object value) { @@ -96,9 +96,9 @@ public class DefaultToStringUserType implements UserType, ParameterizedType { * Are the two objects equal? * * @param x - * an object to compare. + * an object to compare. * @param y - * an object to compare. + * an object to compare. * @return a standard equals test between the objects. */ public boolean equals(Object x, Object y) { @@ -113,17 +113,19 @@ public class DefaultToStringUserType implements UserType, ParameterizedType { * Populate the model object property from the ResultSet. * * @param resultSet - * the non-null ResultSet from which the field will be populated. + * the non-null ResultSet from which the field will be populated. * @param names - * the names of the columns. + * the names of the columns. * @param owner - * the owning object. - * @return null if the column's value is null; otherwise, use the EMF factory to construct a new instance of the - * custom EMF data type from the contents of the String value of the column. + * the owning object. + * @return null if the column's value is null; otherwise, use the EMF factory to construct a new + * instance of the custom EMF data type from the contents of the String value of the + * column. * @throws SQLException - * if the value cannot be retrieved from the ResultSet. + * if the value cannot be retrieved from the ResultSet. */ - public Object nullSafeGet(ResultSet resultSet, String[] names, SessionImplementor sessionImplementor, Object owner) throws SQLException { + public Object nullSafeGet(ResultSet resultSet, String[] names, + SessionImplementor sessionImplementor, Object owner) throws SQLException { String data = resultSet.getString(names[0]); if (data == null) { @@ -136,15 +138,16 @@ public class DefaultToStringUserType implements UserType, ParameterizedType { * Populate the database statement from the model object property. * * @param statement - * the non-null Statement to insert the value into. + * the non-null Statement to insert the value into. * @param value - * the object to convert. + * the object to convert. * @param index - * the index into the statement where to insert the converted value. + * the index into the statement where to insert the converted value. * @throws SQLException - * if the converted value cannot be set in the statement. + * if the converted value cannot be set in the statement. */ - public void nullSafeSet(PreparedStatement statement, Object value, int index, SessionImplementor sessionImplementor) throws SQLException { + public void nullSafeSet(PreparedStatement statement, Object value, int index, + SessionImplementor sessionImplementor) throws SQLException { String pvalue = null; if (value != null) { pvalue = this.eFactory.convertToString(this.eDataType, value); @@ -160,7 +163,7 @@ public class DefaultToStringUserType implements UserType, ParameterizedType { * No-op implementation. * * @param value - * the value to dissemble. + * the value to dissemble. * @return the value passed in. */ public Serializable disassemble(Object value) { @@ -171,9 +174,9 @@ public class DefaultToStringUserType implements UserType, ParameterizedType { * No-op implementation. * * @param cachedValue - * the value to assemble. + * the value to assemble. * @param owner - * the owning object. + * the owning object. * @return the cachedValue passed in. */ public Object assemble(Serializable cachedValue, Object owner) { @@ -184,11 +187,11 @@ public class DefaultToStringUserType implements UserType, ParameterizedType { * No-op implementation. * * @param original - * the value to replace. + * the value to replace. * @param target - * the target object. + * the target object. * @param owner - * the owning object. + * the owning object. * @return the original value passed in. */ public Object replace(Object original, Object target, Object owner) { @@ -199,7 +202,7 @@ public class DefaultToStringUserType implements UserType, ParameterizedType { * No-op implementation. * * @param x - * the object to get the hashcode for. + * the object to get the hashcode for. * @return x's hashcode. */ public int hashCode(Object x) { @@ -210,11 +213,13 @@ public class DefaultToStringUserType implements UserType, ParameterizedType { * ParameterizedType implementation ************************************************************************/ /** - * Read in the type parameters from the Hibernate mapping and determine the EMF factory and custom data type to use. + * Read in the type parameters from the Hibernate mapping and determine the EMF factory and custom + * data type to use. * * @param properties - * the properties containing key value pairs for the {@link #PACKAGE_IMPLEMENTATION_CLASS_NAME_PROPERTY} - * and {@link #ATTRIBUTE_NAME_PROPERTY} parameters. + * the properties containing key value pairs for the + * {@link #PACKAGE_IMPLEMENTATION_CLASS_NAME_PROPERTY} and + * {@link #ATTRIBUTE_NAME_PROPERTY} parameters. */ public void setParameterValues(Properties properties) { final String ePackageNsUri = properties.getProperty(HbMapperConstants.EPACKAGE_PARAM); @@ -237,11 +242,11 @@ public class DefaultToStringUserType implements UserType, ParameterizedType { this.eDataType = (EDataType) eclassifier; } else { if (eclassifier == null) { - throw new IllegalArgumentException("Missing attribute " + edatatypeName + " in package implementation " - + epackage.getName()); + throw new IllegalArgumentException("Missing attribute " + edatatypeName + + " in package implementation " + epackage.getName()); } else { - throw new IllegalArgumentException("Found property of type " + eclassifier.getClass().getName() - + " when an EDataType was expected."); + throw new IllegalArgumentException("Found property of type " + + eclassifier.getClass().getName() + " when an EDataType was expected."); } } } diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/DynamicENumUserIntegerType.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/DynamicENumUserIntegerType.java index da0af8048..eeb60511b 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/DynamicENumUserIntegerType.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/DynamicENumUserIntegerType.java @@ -45,9 +45,10 @@ public class DynamicENumUserIntegerType extends DynamicENumUserType { * (non-Javadoc) * * @see org.hibernate.usertype.UserType#nullSafeGet(java.sql.ResultSet, java.lang.String[], - * java.lang.Object) + * java.lang.Object) */ - public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor sessionImplementor, Object owner) throws HibernateException, SQLException { + public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor sessionImplementor, + Object owner) throws HibernateException, SQLException { final int value = rs.getInt(names[0]); if (rs.wasNull()) { return null; @@ -67,11 +68,12 @@ public class DynamicENumUserIntegerType extends DynamicENumUserType { /* * (non-Javadoc) * - * @see org.hibernate.usertype.UserType#nullSafeSet(java.sql.PreparedStatement, - * java.lang.Object, int) + * @see org.hibernate.usertype.UserType#nullSafeSet(java.sql.PreparedStatement, java.lang.Object, + * int) */ @Override - public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor sessionImplementor) throws HibernateException, SQLException { + public void nullSafeSet(PreparedStatement st, Object value, int index, + SessionImplementor sessionImplementor) throws HibernateException, SQLException { if (value == null) { st.setNull(index, Types.INTEGER); } else { diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/DynamicENumUserType.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/DynamicENumUserType.java index a7498d291..9083edcdc 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/DynamicENumUserType.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/DynamicENumUserType.java @@ -119,9 +119,11 @@ public class DynamicENumUserType implements UserType, ParameterizedType { /* * (non-Javadoc) * - * @see org.hibernate.usertype.UserType#nullSafeGet(java.sql.ResultSet, java.lang.String[], java.lang.Object) + * @see org.hibernate.usertype.UserType#nullSafeGet(java.sql.ResultSet, java.lang.String[], + * java.lang.Object) */ - public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor sessionImplementor, Object owner) throws HibernateException, SQLException { + public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor sessionImplementor, + Object owner) throws HibernateException, SQLException { final String name = rs.getString(names[0]); if (rs.wasNull()) { return null; @@ -144,9 +146,11 @@ public class DynamicENumUserType implements UserType, ParameterizedType { /* * (non-Javadoc) * - * @see org.hibernate.usertype.UserType#nullSafeSet(java.sql.PreparedStatement, java.lang.Object, int) + * @see org.hibernate.usertype.UserType#nullSafeSet(java.sql.PreparedStatement, java.lang.Object, + * int) */ - public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor sessionImplementor) throws HibernateException, SQLException { + public void nullSafeSet(PreparedStatement st, Object value, int index, + SessionImplementor sessionImplementor) throws HibernateException, SQLException { if (value == null) { st.setNull(index, Types.VARCHAR); } else { @@ -157,7 +161,8 @@ public class DynamicENumUserType implements UserType, ParameterizedType { /* * (non-Javadoc) * - * @see org.hibernate.usertype.UserType#replace(java.lang.Object, java.lang.Object, java.lang.Object) + * @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; diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/EMFInitializeCollectionEventListener.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/EMFInitializeCollectionEventListener.java index e4ea4b417..76dfdcdd2 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/EMFInitializeCollectionEventListener.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/EMFInitializeCollectionEventListener.java @@ -27,15 +27,16 @@ import org.hibernate.event.spi.InitializeCollectionEvent; * * @author <a href="mailto:mtaal@elver.org">Mike Kanaley</a> */ -public class EMFInitializeCollectionEventListener extends DefaultInitializeCollectionEventListener implements - ExtensionPoint { +public class EMFInitializeCollectionEventListener extends DefaultInitializeCollectionEventListener + implements ExtensionPoint { private static final long serialVersionUID = 1L; /* * (non-Javadoc) * - * @see org.hibernate.event.def.DefaultInitializeCollectionEventListener#onInitializeCollection(org.hibernate.event.InitializeCollectionEvent) + * @see org.hibernate.event.def.DefaultInitializeCollectionEventListener# + * onInitializeCollection(org.hibernate.event.InitializeCollectionEvent) */ @Override public void onInitializeCollection(InitializeCollectionEvent event) throws HibernateException { diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/ENumUserIntegerType.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/ENumUserIntegerType.java index 7ecec8c23..ac042d583 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/ENumUserIntegerType.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/ENumUserIntegerType.java @@ -23,7 +23,7 @@ import org.hibernate.engine.spi.SessionImplementor; */ public class ENumUserIntegerType extends ENumUserType { - + /** The sql types used for enums */ private static final int[] SQL_TYPES = new int[] { Types.INTEGER }; @@ -33,10 +33,12 @@ public class ENumUserIntegerType extends ENumUserType { /* * (non-Javadoc) * - * @see org.hibernate.usertype.UserType#nullSafeGet(java.sql.ResultSet, java.lang.String[], java.lang.Object) + * @see org.hibernate.usertype.UserType#nullSafeGet(java.sql.ResultSet, java.lang.String[], + * java.lang.Object) */ @Override - public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor sessionImplementor, Object owner) throws HibernateException, SQLException { + public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor sessionImplementor, + Object owner) throws HibernateException, SQLException { final int value = rs.getInt(names[0]); if (rs.wasNull()) return null; @@ -61,10 +63,12 @@ public class ENumUserIntegerType extends ENumUserType { /* * (non-Javadoc) * - * @see org.hibernate.usertype.UserType#nullSafeSet(java.sql.PreparedStatement, java.lang.Object, int) + * @see org.hibernate.usertype.UserType#nullSafeSet(java.sql.PreparedStatement, java.lang.Object, + * int) */ @Override - public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor sessionImplementor) throws HibernateException, SQLException { + public void nullSafeSet(PreparedStatement st, Object value, int index, + SessionImplementor sessionImplementor) throws HibernateException, SQLException { if (value == null) { st.setNull(index, Types.INTEGER); } else { diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/ENumUserType.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/ENumUserType.java index ea6212420..f93eb4dbd 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/ENumUserType.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/ENumUserType.java @@ -119,9 +119,10 @@ public class ENumUserType implements UserType, ParameterizedType { * (non-Javadoc) * * @see org.hibernate.usertype.UserType#nullSafeGet(java.sql.ResultSet, java.lang.String[], - * java.lang.Object) + * java.lang.Object) */ - public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor sessionImplementor, Object owner) throws HibernateException, SQLException { + public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor sessionImplementor, + Object owner) throws HibernateException, SQLException { final String name = rs.getString(names[0]); if (rs.wasNull()) { return null; @@ -136,12 +137,12 @@ public class ENumUserType implements UserType, ParameterizedType { try { enumValue = (Enumerator) getMethod.invoke(null, new Object[] { name.trim() }); } catch (Exception e) { - throw new HbMapperException("Exception when getting enum for class: " + enumType.getName() + - " using value: " + name, e); + throw new HbMapperException("Exception when getting enum for class: " + enumType.getName() + + " using value: " + name, e); } if (enumValue == null) { - throw new HbMapperException("The enum value " + name + " is not valid for enumerator: " + - enumType.getName()); + throw new HbMapperException("The enum value " + name + " is not valid for enumerator: " + + enumType.getName()); } localCache.put(name, enumValue); @@ -151,10 +152,11 @@ public class ENumUserType implements UserType, ParameterizedType { /* * (non-Javadoc) * - * @see org.hibernate.usertype.UserType#nullSafeSet(java.sql.PreparedStatement, - * java.lang.Object, int) + * @see org.hibernate.usertype.UserType#nullSafeSet(java.sql.PreparedStatement, java.lang.Object, + * int) */ - public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor sessionImplementor) throws HibernateException, SQLException { + public void nullSafeSet(PreparedStatement st, Object value, int index, + SessionImplementor sessionImplementor) throws HibernateException, SQLException { if (value == null) { st.setNull(index, Types.VARCHAR); } else { @@ -166,7 +168,7 @@ public class ENumUserType implements UserType, ParameterizedType { * (non-Javadoc) * * @see org.hibernate.usertype.UserType#replace(java.lang.Object, java.lang.Object, - * java.lang.Object) + * java.lang.Object) */ public Object replace(Object original, Object target, Object owner) throws HibernateException { return original; diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/EcoreModelElementType.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/EcoreModelElementType.java index 044f2d991..3f252e9ef 100644 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/EcoreModelElementType.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/EcoreModelElementType.java @@ -34,8 +34,7 @@ import org.hibernate.usertype.ParameterizedType; import org.hibernate.usertype.UserType; /** - * Persists references to EClassifiers and EStructuralFeatures as a varchar - * field. + * Persists references to EClassifiers and EStructuralFeatures as a varchar field. * * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> * @version $Revision: 1.5 $ $Date: 2011/02/27 20:10:36 $ @@ -52,8 +51,7 @@ public class EcoreModelElementType implements UserType, ParameterizedType { registry = PackageRegistryProvider.getInstance().getPackageRegistry(); } - public Object assemble(Serializable cached, Object owner) - throws HibernateException { + public Object assemble(Serializable cached, Object owner) throws HibernateException { return convertFromString((String) cached); } @@ -88,8 +86,8 @@ public class EcoreModelElementType implements UserType, ParameterizedType { return false; } - public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor sessionImplementor, Object owner) - throws HibernateException, SQLException { + public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor sessionImplementor, + Object owner) throws HibernateException, SQLException { final String value = rs.getString(names[0]); if (rs.wasNull()) { return null; @@ -105,21 +103,19 @@ public class EcoreModelElementType implements UserType, ParameterizedType { return ePackage; } else if (values.length == 2) { // EClassifier final String eClassifierName = values[1]; - final EClassifier eClassifier = ePackage - .getEClassifier(eClassifierName); + final EClassifier eClassifier = ePackage.getEClassifier(eClassifierName); return eClassifier; } else { final String eClassifierName = values[1]; - final EClassifier eClassifier = ePackage - .getEClassifier(eClassifierName); + final EClassifier eClassifier = ePackage.getEClassifier(eClassifierName); final EClass eClass = (EClass) eClassifier; final String eFeatureName = values[2]; return eClass.getEStructuralFeature(eFeatureName); } } - public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor sessionImplementor) - throws HibernateException, SQLException { + public void nullSafeSet(PreparedStatement st, Object value, int index, + SessionImplementor sessionImplementor) throws HibernateException, SQLException { if (value == null) { st.setNull(index, Types.VARCHAR); } else { @@ -140,16 +136,14 @@ public class EcoreModelElementType implements UserType, ParameterizedType { } else { final EStructuralFeature feature = (EStructuralFeature) value; - final String uri = feature.getEContainingClass().getEPackage() - .getNsURI(); + final String uri = feature.getEContainingClass().getEPackage().getNsURI(); final String eClassName = feature.getEContainingClass().getName(); final String eFeatureName = feature.getName(); return uri + SEPARATOR + eClassName + SEPARATOR + eFeatureName; } } - public Object replace(Object original, Object target, Object owner) - throws HibernateException { + public Object replace(Object original, Object target, Object owner) throws HibernateException { return original; } diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/ExternalType.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/ExternalType.java index 6a577472c..729ef0cad 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/ExternalType.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/ExternalType.java @@ -34,7 +34,8 @@ import org.hibernate.usertype.ParameterizedType; import org.hibernate.usertype.UserType; /** - * Provides a way to store external references (references to objects not in the same datastore) as a string/uri. + * Provides a way to store external references (references to objects not in the same datastore) as + * a string/uri. * * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> */ @@ -75,7 +76,8 @@ public class ExternalType implements UserType, ParameterizedType { return x.equals(y); } - public Object nullSafeGet(ResultSet resultSet, String[] names, SessionImplementor sessionImplementor, Object owner) throws SQLException { + public Object nullSafeGet(ResultSet resultSet, String[] names, + SessionImplementor sessionImplementor, Object owner) throws SQLException { final String data = resultSet.getString(names[0]); if (data == null) { @@ -83,13 +85,15 @@ public class ExternalType implements UserType, ParameterizedType { } // now create a new instance and set its proxyuri - final InternalEObject newValue = (InternalEObject) eClass.getEPackage().getEFactoryInstance().create(eClass); + final InternalEObject newValue = (InternalEObject) eClass.getEPackage().getEFactoryInstance() + .create(eClass); final URI uri = URI.createURI(data); newValue.eSetProxyURI(uri); return newValue; } - public void nullSafeSet(PreparedStatement statement, Object value, int index, SessionImplementor sessionImplementor) throws SQLException { + public void nullSafeSet(PreparedStatement statement, Object value, int index, + SessionImplementor sessionImplementor) throws SQLException { String pvalue = null; if (value != null) { final Resource res = ((InternalEObject) value).eResource(); @@ -141,11 +145,11 @@ public class ExternalType implements UserType, ParameterizedType { eClass = (EClass) eclassifier; } else { if (eclassifier == null) { - throw new IllegalArgumentException("Missing eClass " + eClassName + " in package implementation " - + epackage.getName()); + throw new IllegalArgumentException("Missing eClass " + eClassName + + " in package implementation " + epackage.getName()); } else { - throw new IllegalArgumentException("Found property of type " + eclassifier.getClass().getName() - + " when an EClass was expected."); + throw new IllegalArgumentException("Found property of type " + + eclassifier.getClass().getName() + " when an EClass was expected."); } } } diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/HibernatePersistentStoreAdapter.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/HibernatePersistentStoreAdapter.java index b7e9a2c1c..283944379 100644 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/HibernatePersistentStoreAdapter.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/HibernatePersistentStoreAdapter.java @@ -29,33 +29,28 @@ import org.eclipse.emf.teneo.type.PersistentStoreAdapter; /** * See superclass. * - * This class adds translation of featuremapentries to hibernate feature map - * entries. + * This class adds translation of featuremapentries to hibernate feature map entries. * * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> * @version $Revision: 1.1 $ */ public class HibernatePersistentStoreAdapter extends PersistentStoreAdapter { - private static final long serialVersionUID = 1L; @Override protected Object replaceValue(Object value, EStructuralFeature eFeature) { if (value instanceof FeatureMap.Entry) { final FeatureMap.Entry entry = (FeatureMap.Entry) value; final HibernateFeatureMapEntry fme = new HibernateFeatureMapEntry(); - fme.setFeatureValue(entry.getEStructuralFeature(), - entry.getValue(), - (FeatureMap.Internal) ((EObject) getTarget()) - .eGet(eFeature)); + fme.setFeatureValue(entry.getEStructuralFeature(), entry.getValue(), + (FeatureMap.Internal) ((EObject) getTarget()).eGet(eFeature)); return fme; } return value; } @Override - protected List<Object> replaceValues(List<Object> values, - EStructuralFeature eFeature) { + protected List<Object> replaceValues(List<Object> values, EStructuralFeature eFeature) { final List<Object> result = new ArrayList<Object>(); for (Object value : values) { result.add(replaceValue(value, eFeature)); diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/QNameUserType.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/QNameUserType.java index cc892511d..5764a2ae9 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/QNameUserType.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/QNameUserType.java @@ -107,9 +107,10 @@ public class QNameUserType implements UserType { * (non-Javadoc) * * @see org.hibernate.usertype.UserType#nullSafeGet(java.sql.ResultSet, java.lang.String[], - * java.lang.Object) + * java.lang.Object) */ - public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor sessionImplementor, Object owner) throws HibernateException, SQLException { + public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor sessionImplementor, + Object owner) throws HibernateException, SQLException { final String str = rs.getString(names[0]); if (rs.wasNull()) { return null; @@ -120,10 +121,11 @@ public class QNameUserType implements UserType { /* * (non-Javadoc) * - * @see org.hibernate.usertype.UserType#nullSafeSet(java.sql.PreparedStatement, - * java.lang.Object, int) + * @see org.hibernate.usertype.UserType#nullSafeSet(java.sql.PreparedStatement, java.lang.Object, + * int) */ - public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor sessionImplementor) throws HibernateException, SQLException { + public void nullSafeSet(PreparedStatement st, Object value, int index, + SessionImplementor sessionImplementor) throws HibernateException, SQLException { if (value == null) { st.setNull(index, Types.VARCHAR); } else { @@ -135,7 +137,7 @@ public class QNameUserType implements UserType { * (non-Javadoc) * * @see org.hibernate.usertype.UserType#replace(java.lang.Object, java.lang.Object, - * java.lang.Object) + * java.lang.Object) */ public Object replace(Object original, Object target, Object owner) throws HibernateException { return original; @@ -157,16 +159,18 @@ public class QNameUserType implements UserType { protected QName convertFromString(String str) { if (str.indexOf("{") == -1) { - throw new HbStoreException("String " + str + " can not be converted to a QName, missing starting {"); + throw new HbStoreException("String " + str + + " can not be converted to a QName, missing starting {"); } final int endIndexNS = str.indexOf("}"); if (endIndexNS == -1) { - throw new HbStoreException("String " + str + - " can not be converted to a QName, missing end ns delimiter } "); + throw new HbStoreException("String " + str + + " can not be converted to a QName, missing end ns delimiter } "); } final int prefixIndex = str.indexOf(":", endIndexNS); if (prefixIndex == -1) { - throw new HbStoreException("String " + str + " can not be converted to a QName, missing prefix delimiter :"); + throw new HbStoreException("String " + str + + " can not be converted to a QName, missing prefix delimiter :"); } final String ns = str.substring(1, endIndexNS); final String prefix = str.substring(endIndexNS + 1, prefixIndex); diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/SerializableDynamicEObjectImpl.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/SerializableDynamicEObjectImpl.java index 4747f4c44..899aa9b60 100644 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/SerializableDynamicEObjectImpl.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/SerializableDynamicEObjectImpl.java @@ -23,7 +23,7 @@ import org.eclipse.emf.ecore.impl.DynamicEObjectImpl; /** * A DynamicEObjectImpl which implements Serializable. This is required by Hibernate. * - * TODO: probably serialization code has to be added to actually support serialization of a + * TODO: probably serialization code has to be added to actually support serialization of a * DynamicEObjectImpl. Often however Hibernate won't really serialize the object, so it might not be * necessary for most cases. * @@ -31,9 +31,10 @@ import org.eclipse.emf.ecore.impl.DynamicEObjectImpl; * * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> * @version $Revision: 1.2 $ - */ -public class SerializableDynamicEObjectImpl extends DynamicEObjectImpl implements Serializable, Map<String, Object> { - + */ +public class SerializableDynamicEObjectImpl extends DynamicEObjectImpl implements Serializable, + Map<String, Object> { + private static final long serialVersionUID = 1L; public SerializableDynamicEObjectImpl(EClass eClass) { @@ -53,7 +54,7 @@ public class SerializableDynamicEObjectImpl extends DynamicEObjectImpl implement if (!(key instanceof String)) { return false; } - final String keyString = (String)key; + final String keyString = (String) key; final EStructuralFeature eFeature = eClass().getEStructuralFeature(keyString); if (eFeature == null) { return false; @@ -66,7 +67,7 @@ public class SerializableDynamicEObjectImpl extends DynamicEObjectImpl implement return false; } for (EStructuralFeature eFeature : eClass().getEAllStructuralFeatures()) { - final Object featureValue = eGet(eFeature); + final Object featureValue = eGet(eFeature); if (featureValue != null && value.equals(featureValue)) { return true; } @@ -75,7 +76,7 @@ public class SerializableDynamicEObjectImpl extends DynamicEObjectImpl implement } public Object get(Object key) { - return eGet(eClass().getEStructuralFeature((String)key)); + return eGet(eClass().getEStructuralFeature((String) key)); } public Object put(String key, Object value) { @@ -86,7 +87,7 @@ public class SerializableDynamicEObjectImpl extends DynamicEObjectImpl implement public Object remove(Object key) { final Object value = get(key); - eSet(eClass().getEStructuralFeature((String)key), null); + eSet(eClass().getEStructuralFeature((String) key), null); return value; } diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/XSDDate.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/XSDDate.java index 9a506ec8a..4aca5b54c 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/XSDDate.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/XSDDate.java @@ -90,7 +90,8 @@ public class XSDDate extends XSDDateTime { */ @Override public void set(PreparedStatement statement, Object value, int index) throws SQLException { - java.sql.Date d = new java.sql.Date(((XMLGregorianCalendar) value).toGregorianCalendar().getTime().getTime()); + java.sql.Date d = new java.sql.Date(((XMLGregorianCalendar) value).toGregorianCalendar() + .getTime().getTime()); statement.setDate(index, d); } diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/XSDDateTime.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/XSDDateTime.java index a026fde8a..810f7c2c6 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/XSDDateTime.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/XSDDateTime.java @@ -32,8 +32,7 @@ import org.hibernate.HibernateException; import org.hibernate.type.MutableType; /** - * Implements the hibernate UserType for EMF's XMLGregorianCalendar ("datetime" - * type in XSD). + * Implements the hibernate UserType for EMF's XMLGregorianCalendar ("datetime" type in XSD). * * @author <a href="mailto:bvetter@alterpoint.com">Brian Vetter</a> * @version $Revision @@ -71,9 +70,8 @@ public class XSDDateTime extends MutableType { */ @Override public Object deepCopyNotNull(Object value) { - return dataTypeFactory - .newXMLGregorianCalendar(((XMLGregorianCalendar) value) - .toGregorianCalendar()); + return dataTypeFactory.newXMLGregorianCalendar(((XMLGregorianCalendar) value) + .toGregorianCalendar()); } /* @@ -95,8 +93,7 @@ public class XSDDateTime extends MutableType { } /* - * @see org.hibernate.type.NullableType#isEqual(java.lang.Object, - * java.lang.Object) + * @see org.hibernate.type.NullableType#isEqual(java.lang.Object, java.lang.Object) */ @Override public boolean isEqual(Object x, Object y) throws HibernateException { @@ -115,8 +112,7 @@ public class XSDDateTime extends MutableType { /* * Transform the date in the resultSet into a XMLGregorianCalendar instance. * - * @see org.hibernate.type.NullableType#get(java.sql.ResultSet, - * java.lang.String) + * @see org.hibernate.type.NullableType#get(java.sql.ResultSet, java.lang.String) */ @Override public Object get(ResultSet resultSet, String name) throws SQLException { @@ -129,17 +125,14 @@ public class XSDDateTime extends MutableType { } /* - * Transform the XMLGregorianCalendar into a timestamp type to store in the - * database + * Transform the XMLGregorianCalendar into a timestamp type to store in the database * - * @see org.hibernate.type.NullableType#set(java.sql.PreparedStatement, - * java.lang.Object, int) + * @see org.hibernate.type.NullableType#set(java.sql.PreparedStatement, java.lang.Object, int) */ @Override - public void set(PreparedStatement statement, Object value, int index) - throws SQLException { - Timestamp d = new Timestamp(((XMLGregorianCalendar) value) - .toGregorianCalendar().getTime().getTime()); + public void set(PreparedStatement statement, Object value, int index) throws SQLException { + Timestamp d = new Timestamp(((XMLGregorianCalendar) value).toGregorianCalendar().getTime() + .getTime()); statement.setTimestamp(index, d); } diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/XSDDuration.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/XSDDuration.java index 7f1c5ff53..c904f6aac 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/XSDDuration.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/XSDDuration.java @@ -81,7 +81,7 @@ public class XSDDuration implements UserType { * Provide a copy of the datatypes. Converts to String and then back to datatype again. * * @param value - * the value to copy. + * the value to copy. * @return the value always. */ public Object deepCopy(Object value) { @@ -95,9 +95,9 @@ public class XSDDuration implements UserType { * Are the two objects equal? * * @param x - * an object to compare. + * an object to compare. * @param y - * an object to compare. + * an object to compare. * @return a standard equals test between the objects. */ public boolean equals(Object x, Object y) { @@ -114,18 +114,19 @@ public class XSDDuration implements UserType { * Populate the model object property from the ResultSet. * * @param resultSet - * the non-null ResultSet from which the field will be populated. + * the non-null ResultSet from which the field will be populated. * @param names - * the names of the columns. + * the names of the columns. * @param owner - * the owning object. + * the owning object. * @return null if the column's value is null; otherwise, use the EMF factory to construct a new * instance of the custom EMF data type from the contents of the String value of the * column. * @throws SQLException - * if the value cannot be retrieved from the ResultSet. + * if the value cannot be retrieved from the ResultSet. */ - public Object nullSafeGet(ResultSet resultSet, String[] names, SessionImplementor sessionImplementor, Object owner) throws SQLException { + public Object nullSafeGet(ResultSet resultSet, String[] names, + SessionImplementor sessionImplementor, Object owner) throws SQLException { final String data = resultSet.getString(names[0]); if (data == null) { @@ -138,15 +139,16 @@ public class XSDDuration implements UserType { * Populate the database statement from the model object property. * * @param statement - * the non-null Statement to insert the value into. + * the non-null Statement to insert the value into. * @param value - * the object to convert. + * the object to convert. * @param index - * the index into the statement where to insert the converted value. + * the index into the statement where to insert the converted value. * @throws SQLException - * if the converted value cannot be set in the statement. + * if the converted value cannot be set in the statement. */ - public void nullSafeSet(PreparedStatement statement, Object value, int index, SessionImplementor sessionImplementor) throws SQLException { + public void nullSafeSet(PreparedStatement statement, Object value, int index, + SessionImplementor sessionImplementor) throws SQLException { String pvalue = null; if (value != null) { pvalue = ((Duration) value).toString(); @@ -162,7 +164,7 @@ public class XSDDuration implements UserType { * No-op implementation. * * @param value - * the value to dissemble. + * the value to dissemble. * @return the value passed in. */ public Serializable disassemble(Object value) { @@ -176,9 +178,9 @@ public class XSDDuration implements UserType { * No-op implementation. * * @param cachedValue - * the value to assemble. + * the value to assemble. * @param owner - * the owning object. + * the owning object. * @return the cachedValue passed in. */ public Object assemble(Serializable cachedValue, Object owner) { @@ -189,11 +191,11 @@ public class XSDDuration implements UserType { * No-op implementation. * * @param original - * the value to replace. + * the value to replace. * @param target - * the target object. + * the target object. * @param owner - * the owning object. + * the owning object. * @return the original value passed in. */ public Object replace(Object original, Object target, Object owner) { @@ -204,7 +206,7 @@ public class XSDDuration implements UserType { * No-op implementation. * * @param x - * the object to get the hashcode for. + * the object to get the hashcode for. * @return x's hashcode. */ public int hashCode(Object x) { diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVDelegatingEMap.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVDelegatingEMap.java index a0b7d491f..0ff1d9e71 100644 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVDelegatingEMap.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVDelegatingEMap.java @@ -41,8 +41,7 @@ import org.hibernate.collection.spi.PersistentCollection; import org.hibernate.engine.spi.SessionImplementor; /** - * The emap which initializes itself from the persistent collection when first - * accessed. + * The emap which initializes itself from the persistent collection when first accessed. * * @author <a href="mtaal@elver.org">Martin Taal</a> */ @@ -50,7 +49,6 @@ public class EAVDelegatingEMap<K, V> implements EMap<K, V>, EAVDelegatingList, InternalEList.Unsettable<Map.Entry<K, V>>, EStructuralFeature.Setting, PersistableDelegateList<Map.Entry<K, V>> { - private static final long serialVersionUID = 1L; private List<EAVValueHolder> persistentList; private EcoreEMap<K, V> delegatingEMap; private EClass entryEClass; @@ -60,8 +58,8 @@ public class EAVDelegatingEMap<K, V> implements EMap<K, V>, EAVDelegatingList, private EStructuralFeature eStructuralFeature; private EAVMultiValueHolder valueHolderOwner; - public EAVDelegatingEMap(EClass entryEClass, Class<?> entryClass, - InternalEObject owner, int featureID) { + public EAVDelegatingEMap(EClass entryEClass, Class<?> entryClass, InternalEObject owner, + int featureID) { this.entryClass = entryClass; this.entryEClass = entryEClass; this.owner = owner; @@ -77,16 +75,14 @@ public class EAVDelegatingEMap<K, V> implements EMap<K, V>, EAVDelegatingList, if (delegatingEMap != null) { return; } - delegatingEMap = new EcoreEMap<K, V>(entryEClass, entryClass, owner, - featureID); + delegatingEMap = new EcoreEMap<K, V>(entryEClass, entryClass, owner, featureID); int index = 0; for (Object obj : persistentList) { EAVSingleContainmentEReferenceValueHolder valueHolder = (EAVSingleContainmentEReferenceValueHolder) obj; valueHolder.setListIndex(index++); valueHolder.setValueOwner(getValueHolderOwner()); - delegatingEMap.basicAdd((BasicEMap.Entry<K, V>) valueHolder - .getReferenceValue(), null); + delegatingEMap.basicAdd((BasicEMap.Entry<K, V>) valueHolder.getReferenceValue(), null); } // force the map to be computed, this sets the internal entrydata/size // member @@ -108,8 +104,7 @@ public class EAVDelegatingEMap<K, V> implements EMap<K, V>, EAVDelegatingList, return delegatingEMap.addAll(collection); } - public boolean addAll(int index, - Collection<? extends Entry<K, V>> collection) { + public boolean addAll(int index, Collection<? extends Entry<K, V>> collection) { initialize(); return delegatingEMap.addAll(index, collection); } @@ -119,8 +114,7 @@ public class EAVDelegatingEMap<K, V> implements EMap<K, V>, EAVDelegatingList, return delegatingEMap.addAllUnique(collection); } - public boolean addAllUnique(int index, - Collection<? extends Entry<K, V>> collection) { + public boolean addAllUnique(int index, Collection<? extends Entry<K, V>> collection) { initialize(); return delegatingEMap.addAllUnique(index, collection); } @@ -135,8 +129,7 @@ public class EAVDelegatingEMap<K, V> implements EMap<K, V>, EAVDelegatingList, delegatingEMap.addUnique(index, object); } - public NotificationChain basicAdd(Entry<K, V> object, - NotificationChain notifications) { + public NotificationChain basicAdd(Entry<K, V> object, NotificationChain notifications) { initialize(); return delegatingEMap.basicAdd(object, notifications); } @@ -186,8 +179,7 @@ public class EAVDelegatingEMap<K, V> implements EMap<K, V>, EAVDelegatingList, return delegatingEMap.basicListIterator(index); } - public NotificationChain basicRemove(Object object, - NotificationChain notifications) { + public NotificationChain basicRemove(Object object, NotificationChain notifications) { initialize(); return delegatingEMap.basicRemove(object, notifications); } @@ -258,59 +250,63 @@ public class EAVDelegatingEMap<K, V> implements EMap<K, V>, EAVDelegatingList, final AbstractPersistentCollection persistentCollection = (AbstractPersistentCollection) getDelegate(); final SessionImplementor sessionImplementor = ((AbstractPersistentCollection) persistentCollection) .getSession(); - final Session session = (Session)sessionImplementor; + final Session session = (Session) sessionImplementor; session.flush(); - - // create a query + + // create a query // the owner is a EAVMultiValueHolder which has a list of referenceValues - // each referenceValue is an EAV_Object which has a values containing - // the key and value values. The key can be a primitive or a - + // each referenceValue is an EAV_Object which has a values containing + // the key and value values. The key can be a primitive or a + final StringBuilder qryStr = new StringBuilder(); - if (((EReference)getEStructuralFeature()).isContainment()) { - qryStr.append("select singleValue from EAVSingleContainmentEReferenceValueHolder singleValue left join fetch singleValue.eavObjectReference"); + if (((EReference) getEStructuralFeature()).isContainment()) { + qryStr + .append("select singleValue from EAVSingleContainmentEReferenceValueHolder singleValue left join fetch singleValue.eavObjectReference"); } else { - qryStr.append("select singleValue.referenceValue from EAVSingleNonContainmentEReferenceValueHolder singleValue left join fetch singleValue.eavObjectReference"); + qryStr + .append("select singleValue.referenceValue from EAVSingleNonContainmentEReferenceValueHolder singleValue left join fetch singleValue.eavObjectReference"); } final EStructuralFeature keyFeature = entryEClass.getEStructuralFeature("key"); final Object keyParameter; if (keyFeature instanceof EReference) { - final EReference eReference = (EReference)keyFeature; + final EReference eReference = (EReference) keyFeature; if (eReference.isContainment()) { - qryStr.append(", EAVSingleContainmentEReferenceValueHolder keyValue where"); + qryStr.append(", EAVSingleContainmentEReferenceValueHolder keyValue where"); } else { - qryStr.append(", EAVSingleNonContainmentEReferenceValueHolder keyValue where"); + qryStr.append(", EAVSingleNonContainmentEReferenceValueHolder keyValue where"); } - + // a reference qryStr.append(" keyValue.referenceValue=:keyParameter "); keyParameter = key; } else { - qryStr.append(", EAVSingleEAttributeValueHolder keyValue where"); + qryStr.append(", EAVSingleEAttributeValueHolder keyValue where"); qryStr.append(" keyValue.typeNeutralValue=:keyParameter"); - final EAttribute eAttribute = (EAttribute)keyFeature; - final EFactory eFactory = eAttribute.getEAttributeType().getEPackage().getEFactoryInstance(); + final EAttribute eAttribute = (EAttribute) keyFeature; + final EFactory eFactory = eAttribute.getEAttributeType().getEPackage() + .getEFactoryInstance(); keyParameter = eFactory.convertToString(eAttribute.getEAttributeType(), key); } - qryStr.append( " and keyValue.feature=:feature and singleValue.eavObjectReference=keyValue.owner and singleValue.valueOwner=:owner"); - + qryStr + .append(" and keyValue.feature=:feature and singleValue.eavObjectReference=keyValue.owner and singleValue.valueOwner=:owner"); + final Query qry = session.createQuery(qryStr.toString()); qry.setParameter("keyParameter", keyParameter); qry.setParameter("feature", keyFeature); qry.setParameter("owner", persistentCollection.getOwner()); for (Object o : qry.list()) { - final EAVSingleEReferenceValueHolder valueHolder = (EAVSingleEReferenceValueHolder)o; + final EAVSingleEReferenceValueHolder valueHolder = (EAVSingleEReferenceValueHolder) o; final Object result = valueHolder.getReferenceValue(); if (!(result instanceof EObject)) { continue; } - - final EObject eContainer = ((EObject)result).eContainer(); + + final EObject eContainer = ((EObject) result).eContainer(); final EObject owner = getEObject(); if (result instanceof Map.Entry<?, ?> && eContainer == owner) { - final Map.Entry<K, V> entry = (Map.Entry<K, V>)result; + final Map.Entry<K, V> entry = (Map.Entry<K, V>) result; return entry.getValue(); - } + } } return null; } @@ -398,14 +394,13 @@ public class EAVDelegatingEMap<K, V> implements EMap<K, V>, EAVDelegatingList, public V put(K key, V value) { if (isExtraLazyAndNotInitialized()) { final Map.Entry<K, V> entry = (Map.Entry<K, V>) get(key); - if (entry != null - && entry instanceof org.eclipse.emf.common.util.BasicEMap.Entry<?, ?>) { + if (entry != null && entry instanceof org.eclipse.emf.common.util.BasicEMap.Entry<?, ?>) { final V result = entry.getValue(); entry.setValue(value); return result; } else { - final EAVValueHolder valueHolder = (EAVValueHolder) getValueHolderOwner() - .getElement(newEntry(key, value)); + final EAVValueHolder valueHolder = (EAVValueHolder) getValueHolderOwner().getElement( + newEntry(key, value)); valueHolder.setListIndex(getPersistentList().size()); getPersistentList().add(valueHolder); return null; @@ -514,7 +509,8 @@ public class EAVDelegatingEMap<K, V> implements EMap<K, V>, EAVDelegatingList, this.persistentList = (List<EAVValueHolder>) persistentList; if (isHibernateListPresent() && getHibernatePersistentList().wasInitialized()) { initialize(); - } if (persistentList instanceof ArrayList<?>) { + } + if (persistentList instanceof ArrayList<?>) { // newly persisted initialize(); } @@ -560,15 +556,12 @@ public class EAVDelegatingEMap<K, V> implements EMap<K, V>, EAVDelegatingList, private final boolean isConnectedToSession(SessionImplementor session) { final PersistentCollection persistentCollection = (PersistentCollection) getDelegate(); - return session != null - && session.isOpen() - && session.getPersistenceContext().containsCollection( - persistentCollection); + return session != null && session.isOpen() + && session.getPersistenceContext().containsCollection(persistentCollection); } private boolean isExtraLazyAndNotInitialized() { - if (!isInitialized() && isHibernateListPresent() - && isConnectedToSession()) { + if (!isInitialized() && isHibernateListPresent() && isConnectedToSession()) { boolean extraLazyLoaded = getValueHolderOwner() instanceof EAVExtraMultiContainmentEReferenceValueHolder; extraLazyLoaded |= getValueHolderOwner() instanceof EAVExtraMultiNonContainmentEReferenceValueHolder; extraLazyLoaded |= getValueHolderOwner() instanceof EAVExtraMultiEAttributeValueHolder; @@ -579,8 +572,8 @@ public class EAVDelegatingEMap<K, V> implements EMap<K, V>, EAVDelegatingList, protected org.eclipse.emf.common.util.BasicEMap.Entry<K, V> newEntry(K key, V value) { @SuppressWarnings("unchecked") - org.eclipse.emf.common.util.BasicEMap.Entry<K, V> entry = (org.eclipse.emf.common.util.BasicEMap.Entry<K, V>) entryEClass.getEPackage() - .getEFactoryInstance().create(entryEClass); + org.eclipse.emf.common.util.BasicEMap.Entry<K, V> entry = (org.eclipse.emf.common.util.BasicEMap.Entry<K, V>) entryEClass + .getEPackage().getEFactoryInstance().create(entryEClass); entry.setHash(key.hashCode()); entry.setKey(key); entry.setValue(value); diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVDelegatingEcoreEList.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVDelegatingEcoreEList.java index 5274804c7..20546a7d3 100644 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVDelegatingEcoreEList.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVDelegatingEcoreEList.java @@ -27,12 +27,11 @@ import org.hibernate.collection.spi.PersistentCollection; import org.hibernate.engine.spi.SessionImplementor; /** - * The list used in instances mapped using the EAV schema. The persistentList is - * the Hibernate list present as the referenceValues in the - * EAVMulti*ContainmentEReferenceValueHolder. + * The list used in instances mapped using the EAV schema. The persistentList is the Hibernate list + * present as the referenceValues in the EAVMulti*ContainmentEReferenceValueHolder. */ -public class EAVDelegatingEcoreEList<E> extends DelegatingEcoreEList<E> - implements EAVDelegatingList, PersistableDelegateList<E> { +public class EAVDelegatingEcoreEList<E> extends DelegatingEcoreEList<E> implements + EAVDelegatingList, PersistableDelegateList<E> { private static final long serialVersionUID = 1L; private EStructuralFeature eStructuralFeature; @@ -100,8 +99,7 @@ public class EAVDelegatingEcoreEList<E> extends DelegatingEcoreEList<E> @SuppressWarnings("unchecked") public void setPersistentList(List<?> persistentList) { this.persistentList = (List<EAVValueHolder>) persistentList; - if (isHibernateListPresent() - && getHibernatePersistentList().wasInitialized()) { + if (isHibernateListPresent() && getHibernatePersistentList().wasInitialized()) { doInitialize(); } else if (persistentList instanceof ArrayList<?>) { // newly persisted @@ -146,16 +144,13 @@ public class EAVDelegatingEcoreEList<E> extends DelegatingEcoreEList<E> private final boolean isConnectedToSession(SessionImplementor session) { final PersistentCollection persistentCollection = (PersistentCollection) getDelegate(); - return session != null - && session.isOpen() - && session.getPersistenceContext().containsCollection( - persistentCollection); + return session != null && session.isOpen() + && session.getPersistenceContext().containsCollection(persistentCollection); } @Override protected void delegateAdd(E object) { - final EAVValueHolder valueHolder = (EAVValueHolder) getValueHolderOwner() - .getElement(object); + final EAVValueHolder valueHolder = (EAVValueHolder) getValueHolderOwner().getElement(object); valueHolder.setListIndex(getHibernatePersistentList().size()); persistentList.add(valueHolder); @@ -175,15 +170,13 @@ public class EAVDelegatingEcoreEList<E> extends DelegatingEcoreEList<E> // insert in the middle, load the whole list delegateList(); - final EAVValueHolder valueHolder = (EAVValueHolder) getValueHolderOwner() - .getElement(object); + final EAVValueHolder valueHolder = (EAVValueHolder) getValueHolderOwner().getElement(object); persistentList.add(index, valueHolder); int newIndex = index; // note, can not use the size() call, must do persistentList.size() - for (EAVValueHolder element : persistentList.subList(index, - persistentList.size())) { + for (EAVValueHolder element : persistentList.subList(index, persistentList.size())) { element.setListIndex(newIndex++); } @@ -254,8 +247,7 @@ public class EAVDelegatingEcoreEList<E> extends DelegatingEcoreEList<E> @Override public Iterator<E> iterator() { - if (!isDelegateInitialized() && isHibernateListPresent() - && isConnectedToSession()) { + if (!isDelegateInitialized() && isHibernateListPresent() && isConnectedToSession()) { boolean extraLazyLoaded = getValueHolderOwner() instanceof EAVExtraMultiContainmentEReferenceValueHolder; extraLazyLoaded |= getValueHolderOwner() instanceof EAVExtraMultiNonContainmentEReferenceValueHolder; extraLazyLoaded |= getValueHolderOwner() instanceof EAVExtraMultiEAttributeValueHolder; @@ -285,16 +277,14 @@ public class EAVDelegatingEcoreEList<E> extends DelegatingEcoreEList<E> final EAVValueHolder result = persistentList.remove(sourceIndex); int newIndex = sourceIndex; - for (EAVValueHolder element : persistentList.subList(sourceIndex, - size())) { + for (EAVValueHolder element : persistentList.subList(sourceIndex, size())) { element.setListIndex(newIndex++); } persistentList.add(targetIndex, result); newIndex = targetIndex; - for (EAVValueHolder element : persistentList.subList(sourceIndex, - size())) { + for (EAVValueHolder element : persistentList.subList(sourceIndex, size())) { element.setListIndex(newIndex++); } return super.delegateMove(targetIndex, sourceIndex); @@ -303,8 +293,7 @@ public class EAVDelegatingEcoreEList<E> extends DelegatingEcoreEList<E> @Override @SuppressWarnings("unchecked") protected E delegateRemove(int index) { - final boolean reallyLazy = index == (size() - 1) - && !isDelegateInitialized(); + final boolean reallyLazy = index == (size() - 1) && !isDelegateInitialized(); if (!reallyLazy) { // force a load before removing delegateList(); @@ -321,8 +310,7 @@ public class EAVDelegatingEcoreEList<E> extends DelegatingEcoreEList<E> int newIndex = index; // must use persistentList.size() as the delegate size has not yet been // updated! - for (EAVValueHolder element : persistentList.subList(index, - persistentList.size())) { + for (EAVValueHolder element : persistentList.subList(index, persistentList.size())) { element.setListIndex(newIndex++); } return super.delegateRemove(index); @@ -331,11 +319,9 @@ public class EAVDelegatingEcoreEList<E> extends DelegatingEcoreEList<E> @SuppressWarnings("unchecked") @Override protected E delegateSet(int index, E object) { - final EAVValueHolder newValueHolder = (EAVValueHolder) getValueHolderOwner() - .getElement(object); + final EAVValueHolder newValueHolder = (EAVValueHolder) getValueHolderOwner().getElement(object); newValueHolder.setListIndex(index); - final EAVValueHolder oldValueHolder = persistentList.set(index, - newValueHolder); + final EAVValueHolder oldValueHolder = persistentList.set(index, newValueHolder); // clear old object if (oldValueHolder != null) { diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVDelegatingList.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVDelegatingList.java index 0056a98d4..f1cd9f061 100644 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVDelegatingList.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVDelegatingList.java @@ -17,6 +17,6 @@ import java.util.List; */ public interface EAVDelegatingList { boolean isDelegateInitialized(); - + void setPersistentList(List<?> persistentList); } diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVExtraMultiContainmentEReferenceValueHolder.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVExtraMultiContainmentEReferenceValueHolder.java index 4cd260c69..4d2f1a6d9 100644 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVExtraMultiContainmentEReferenceValueHolder.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVExtraMultiContainmentEReferenceValueHolder.java @@ -17,11 +17,11 @@ package org.eclipse.emf.teneo.hibernate.mapping.eav; - /** * Variant of super class which loads all lists extra-lazily. * * @author <a href="mtaal@elver.org">Martin Taal</a> */ -public class EAVExtraMultiContainmentEReferenceValueHolder extends EAVMultiContainmentEReferenceValueHolder { +public class EAVExtraMultiContainmentEReferenceValueHolder extends + EAVMultiContainmentEReferenceValueHolder { }
\ No newline at end of file diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVExtraMultiEAttributeValueHolder.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVExtraMultiEAttributeValueHolder.java index 7f397cc7b..4e1de444c 100644 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVExtraMultiEAttributeValueHolder.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVExtraMultiEAttributeValueHolder.java @@ -17,7 +17,6 @@ package org.eclipse.emf.teneo.hibernate.mapping.eav; - /** * Variant of super class which loads all lists extra-lazily. * diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVExtraMultiNonContainmentEReferenceValueHolder.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVExtraMultiNonContainmentEReferenceValueHolder.java index f9c55d73e..c89dd8ad8 100644 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVExtraMultiNonContainmentEReferenceValueHolder.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVExtraMultiNonContainmentEReferenceValueHolder.java @@ -17,11 +17,11 @@ package org.eclipse.emf.teneo.hibernate.mapping.eav; - /** * Variant of super class which loads all lists extra-lazily. * * @author <a href="mtaal@elver.org">Martin Taal</a> */ -public class EAVExtraMultiNonContainmentEReferenceValueHolder extends EAVMultiNonContainmentEReferenceValueHolder { +public class EAVExtraMultiNonContainmentEReferenceValueHolder extends + EAVMultiNonContainmentEReferenceValueHolder { }
\ No newline at end of file diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVFeatureMapEntryValueHolder.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVFeatureMapEntryValueHolder.java index 599a9588c..dcdc77421 100644 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVFeatureMapEntryValueHolder.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVFeatureMapEntryValueHolder.java @@ -65,7 +65,8 @@ public class EAVFeatureMapEntryValueHolder extends EAVSingleEAttributeValueHolde return featureMapEntry; } - featureMapEntry = ((EStructuralFeatureImpl) getEStructuralFeature()).getFeatureMapEntryPrototype(); + featureMapEntry = ((EStructuralFeatureImpl) getEStructuralFeature()) + .getFeatureMapEntryPrototype(); if (isEReference) { featureMapEntry = FeatureMapUtil.createEntry(getEStructuralFeature(), referenceValue); } else { diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVFeatureMapValueHolder.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVFeatureMapValueHolder.java index 60eb6aee4..16ff05cf0 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVFeatureMapValueHolder.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVFeatureMapValueHolder.java @@ -56,7 +56,8 @@ public class EAVFeatureMapValueHolder extends EAVMultiValueHolder { public Object get(InternalEObject owner) { final EAVDelegatingFeatureMap featureMap = new EAVDelegatingFeatureMap((InternalEObject) owner, getEStructuralFeature()); - // final DelegatingLateLoadingList.FeatureMapList objValues = new DelegatingLateLoadingList.FeatureMapList(); + // final DelegatingLateLoadingList.FeatureMapList objValues = new + // DelegatingLateLoadingList.FeatureMapList(); // objValues.setOwner(owner); // objValues.setPersistentList(values); featureMap.setPersistentList(values); diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVGenericIDUserType.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVGenericIDUserType.java index 1f3065b1d..e5cca8a9e 100644 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVGenericIDUserType.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVGenericIDUserType.java @@ -65,10 +65,10 @@ public class EAVGenericIDUserType implements UserType { return x.equals(y); } - public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor sessionImplementor, Object owner) - throws SQLException { - final String value = (String) StandardBasicTypes.STRING.nullSafeGet(rs, - names[0], sessionImplementor); + public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor sessionImplementor, + Object owner) throws SQLException { + final String value = (String) StandardBasicTypes.STRING.nullSafeGet(rs, names[0], + sessionImplementor); if (rs.wasNull()) { return null; } @@ -82,13 +82,12 @@ public class EAVGenericIDUserType implements UserType { return id; } - public void nullSafeSet(PreparedStatement statement, Object value, int index, SessionImplementor sessionImplementor) - throws SQLException { + public void nullSafeSet(PreparedStatement statement, Object value, int index, + SessionImplementor sessionImplementor) throws SQLException { if (value == null) { statement.setNull(index, Types.VARCHAR); } else { - statement.setString(index, value.toString() + SEPARATOR - + value.getClass().getName()); + statement.setString(index, value.toString() + SEPARATOR + value.getClass().getName()); } } @@ -113,15 +112,12 @@ public class EAVGenericIDUserType implements UserType { try { Constructor<?> constructor = constructors.get(idType); if (constructor == null) { - Class<?> idClass = this.getClass().getClassLoader() - .loadClass(idType); - constructor = idClass - .getConstructor(new Class[] { String.class }); + Class<?> idClass = this.getClass().getClassLoader().loadClass(idType); + constructor = idClass.getConstructor(new Class[] { String.class }); constructors.put(idType, constructor); } - return (Serializable) constructor - .newInstance(new Object[] { idStr }); + return (Serializable) constructor.newInstance(new Object[] { idStr }); } catch (Exception e) { throw new IllegalStateException(e); } diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVMultiContainmentEReferenceValueHolder.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVMultiContainmentEReferenceValueHolder.java index e4b598adc..98cf5ec15 100644 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVMultiContainmentEReferenceValueHolder.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVMultiContainmentEReferenceValueHolder.java @@ -30,8 +30,7 @@ import org.eclipse.emf.teneo.util.StoreUtil; * * @author <a href="mtaal@elver.org">Martin Taal</a> */ -public class EAVMultiContainmentEReferenceValueHolder extends - EAVMultiValueHolder { +public class EAVMultiContainmentEReferenceValueHolder extends EAVMultiValueHolder { private List<EAVSingleContainmentEReferenceValueHolder> referenceValues; private EAVDelegatingList ecoreObjectList = null; @@ -72,20 +71,16 @@ public class EAVMultiContainmentEReferenceValueHolder extends private void setEcoreObjectList() { if (StoreUtil.isMap(getEStructuralFeature())) { - final EClass entryEClass = (EClass) getEStructuralFeature() - .getEType(); + final EClass entryEClass = (EClass) getEStructuralFeature().getEType(); Class<?> entryClass = entryEClass.getInstanceClass(); // prevents a failing assertion in the EcoreEMap - if (entryClass == null - || !BasicEMap.Entry.class.isAssignableFrom(entryClass)) { + if (entryClass == null || !BasicEMap.Entry.class.isAssignableFrom(entryClass)) { entryClass = BasicEMap.Entry.class; } - final int featureID = getOwner().eClass().getFeatureID( - getEStructuralFeature()); + final int featureID = getOwner().eClass().getFeatureID(getEStructuralFeature()); final EAVDelegatingEMap<Object, Object> eMap = new EAVDelegatingEMap<Object, Object>( - entryEClass, entryClass, (InternalEObject) getOwner(), - featureID); + entryEClass, entryClass, (InternalEObject) getOwner(), featureID); eMap.setValueHolderOwner(this); ecoreObjectList = eMap; eMap.setEStructuralFeature(getEStructuralFeature()); @@ -112,8 +107,7 @@ public class EAVMultiContainmentEReferenceValueHolder extends return referenceValues; } - public void setReferenceValues( - List<EAVSingleContainmentEReferenceValueHolder> referenceValues) { + public void setReferenceValues(List<EAVSingleContainmentEReferenceValueHolder> referenceValues) { this.referenceValues = referenceValues; if (ecoreObjectList == null) { setEcoreObjectList(); diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVMultiEAttributeValueHolder.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVMultiEAttributeValueHolder.java index 6073060a0..b8d26f60f 100644 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVMultiEAttributeValueHolder.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVMultiEAttributeValueHolder.java @@ -33,7 +33,8 @@ public class EAVMultiEAttributeValueHolder extends EAVMultiValueHolder { private EAVDelegatingList ecoreObjectList = null; public void set(Object value) { - // set to null first, if there is at least one value then it is set to a value + // set to null first, if there is at least one value then it is set to a + // value setMandatoryValue(null); final List<?> listValues = (List<?>) value; values = new ArrayList<EAVSingleEAttributeValueHolder>(); @@ -64,7 +65,8 @@ public class EAVMultiEAttributeValueHolder extends EAVMultiValueHolder { if (ecoreObjectList != null) { return ecoreObjectList; } - final EAVDelegatingEcoreEList<Object> ecoreList = new EAVDelegatingEcoreEList<Object>((InternalEObject) owner); + final EAVDelegatingEcoreEList<Object> ecoreList = new EAVDelegatingEcoreEList<Object>( + (InternalEObject) owner); ecoreList.setValueHolderOwner(this); ecoreList.setEStructuralFeature(getEStructuralFeature()); ecoreList.setPersistentList(values); @@ -78,6 +80,6 @@ public class EAVMultiEAttributeValueHolder extends EAVMultiValueHolder { public void setValues(List<EAVSingleEAttributeValueHolder> values) { this.values = values; - ((EAVDelegatingList)get((InternalEObject)getOwner())).setPersistentList(values); + ((EAVDelegatingList) get((InternalEObject) getOwner())).setPersistentList(values); } }
\ No newline at end of file diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVMultiNonContainmentEReferenceValueHolder.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVMultiNonContainmentEReferenceValueHolder.java index ffa818f57..c59a988b1 100644 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVMultiNonContainmentEReferenceValueHolder.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVMultiNonContainmentEReferenceValueHolder.java @@ -34,7 +34,8 @@ public class EAVMultiNonContainmentEReferenceValueHolder extends EAVMultiValueHo @SuppressWarnings("unchecked") public void set(Object value) { - // set to null first, if there is at least one value then it is set to a value + // set to null first, if there is at least one value then it is set to a + // value setMandatoryValue(null); final List<?> values = (List<Object>) value; referenceValues = new ArrayList<EAVSingleNonContainmentEReferenceValueHolder>(); @@ -61,9 +62,11 @@ public class EAVMultiNonContainmentEReferenceValueHolder extends EAVMultiValueHo if (ecoreObjectList != null) { return ecoreObjectList; } - // final DelegatingLateLoadingList<Object> lateLoadingList = new DelegatingLateLoadingList<Object>(); + // final DelegatingLateLoadingList<Object> lateLoadingList = new + // DelegatingLateLoadingList<Object>(); // lateLoadingList.setPersistentList(referenceValues); - final EAVDelegatingEcoreEList<Object> ecoreList = new EAVDelegatingEcoreEList<Object>((InternalEObject) owner); + final EAVDelegatingEcoreEList<Object> ecoreList = new EAVDelegatingEcoreEList<Object>( + (InternalEObject) owner); ecoreList.setValueHolderOwner(this); ecoreList.setEStructuralFeature(getEStructuralFeature()); ecoreList.setPersistentList(referenceValues); @@ -81,6 +84,6 @@ public class EAVMultiNonContainmentEReferenceValueHolder extends EAVMultiValueHo public void setReferenceValues(List<EAVSingleNonContainmentEReferenceValueHolder> referenceValues) { this.referenceValues = referenceValues; - ((EAVDelegatingList)get((InternalEObject)getOwner())).setPersistentList(referenceValues); + ((EAVDelegatingList) get((InternalEObject) getOwner())).setPersistentList(referenceValues); } }
\ No newline at end of file diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVMultiValueHolder.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVMultiValueHolder.java index dd1278686..d47c58300 100644 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVMultiValueHolder.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVMultiValueHolder.java @@ -32,18 +32,20 @@ import org.eclipse.emf.teneo.util.StoreUtil; * @author <a href="mtaal@elver.org">Martin Taal</a> */ public abstract class EAVMultiValueHolder extends EAVValueHolder { - + public abstract Object getElement(Object value); public void setValueInOwner(InternalEObject owner) { if (!EcoreAccess.isStaticFeature(getEStructuralFeature(), (BasicEObjectImpl) owner)) { - Object currentValue = EcoreAccess.getManyEFeatureValue(getEStructuralFeature(), (BasicEObjectImpl) owner); + Object currentValue = EcoreAccess.getManyEFeatureValue(getEStructuralFeature(), + (BasicEObjectImpl) owner); if (StoreUtil.isEStoreList(currentValue)) { final EStore eStore = owner.eStore(); if (eStore.size(owner, getEStructuralFeature()) != -1) { - currentValue = eStore.get((InternalEObject) owner, getEStructuralFeature(), EStore.NO_INDEX); + currentValue = eStore.get((InternalEObject) owner, getEStructuralFeature(), + EStore.NO_INDEX); } } @@ -54,7 +56,8 @@ public abstract class EAVMultiValueHolder extends EAVValueHolder { final Object newValue = get(owner); EcoreAccess.setManyEFeatureValue(getEStructuralFeature(), newValue, (BasicEObjectImpl) owner); } else { - final Field javaField = FieldUtil.getField(owner.getClass(), getEStructuralFeature().getName()); + final Field javaField = FieldUtil.getField(owner.getClass(), getEStructuralFeature() + .getName()); try { final Object currentValue = javaField.get(owner); diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVObjectTuplizer.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVObjectTuplizer.java index adfa9cd85..02758cd91 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVObjectTuplizer.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVObjectTuplizer.java @@ -70,8 +70,8 @@ public class EAVObjectTuplizer extends AbstractEntityTuplizer { private static Log log = LogFactory.getLog(EAVObjectTuplizer.class); /** - * The mapped class, defaults to EObject for entities and to the real impl - * class for mapped classes + * The mapped class, defaults to EObject for entities and to the real impl class for mapped + * classes */ private Class<?> mappedClass; @@ -80,8 +80,7 @@ public class EAVObjectTuplizer extends AbstractEntityTuplizer { /** The entitymetamodel for which this is all done */ // private final EntityMetamodel theEntityMetamodel; /** Constructor */ - public EAVObjectTuplizer(EntityMetamodel entityMetamodel, - PersistentClass mappedEntity) { + public EAVObjectTuplizer(EntityMetamodel entityMetamodel, PersistentClass mappedEntity) { super(entityMetamodel, mappedEntity); // theEntityMetamodel = entityMetamodel; if (mappedEntity.getMappedClass() != null) { @@ -97,8 +96,7 @@ public class EAVObjectTuplizer extends AbstractEntityTuplizer { */ @Override public Serializable getIdentifier(Object object) throws HibernateException { - Serializable id = (Serializable) IdentifierCacheHandler.getInstance() - .getID(object); + Serializable id = (Serializable) IdentifierCacheHandler.getInstance().getID(object); if (id != null) { return id; } @@ -108,8 +106,7 @@ public class EAVObjectTuplizer extends AbstractEntityTuplizer { /* * (non-Javadoc) * - * @see - * org.hibernate.tuple.entity.EntityTuplizer#determineConcreteSubclassEntityName + * @see org.hibernate.tuple.entity.EntityTuplizer#determineConcreteSubclassEntityName * (java.lang.Object, org.hibernate.engine.SessionFactoryImplementor) */ public String determineConcreteSubclassEntityName(Object entityInstance, @@ -118,14 +115,11 @@ public class EAVObjectTuplizer extends AbstractEntityTuplizer { if (concreteEntityClass == getMappedClass()) { return getEntityName(); } else { - String entityName = getEntityMetamodel() - .findEntityNameByEntityClass(concreteEntityClass); + String entityName = getEntityMetamodel().findEntityNameByEntityClass(concreteEntityClass); if (entityName == null) { - throw new HibernateException( - "Unable to resolve entity name from Class [" - + concreteEntityClass.getName() + "]" - + " expected instance/subclass of [" - + getEntityName() + "]"); + throw new HibernateException("Unable to resolve entity name from Class [" + + concreteEntityClass.getName() + "]" + " expected instance/subclass of [" + + getEntityName() + "]"); } return entityName; } @@ -158,8 +152,7 @@ public class EAVObjectTuplizer extends AbstractEntityTuplizer { * Sets the identifier in the cache. */ @Override - public void setIdentifier(Object object, Serializable id) - throws HibernateException { + public void setIdentifier(Object object, Serializable id) throws HibernateException { IdentifierCacheHandler.getInstance().setID(object, id); super.setIdentifier(object, id); } @@ -167,13 +160,11 @@ public class EAVObjectTuplizer extends AbstractEntityTuplizer { /** Creates an EMF Instantiator */ @Override protected Instantiator buildInstantiator(PersistentClass persistentClass) { - if (persistentClass.getEntityName().equals( - Constants.EAV_EOBJECT_ENTITY_NAME)) { + if (persistentClass.getEntityName().equals(Constants.EAV_EOBJECT_ENTITY_NAME)) { return null; } final HbDataStore ds = HbHelper.INSTANCE.getDataStore(persistentClass); - final EClass eclass = ds.getEntityNameStrategy().toEClass( - persistentClass.getEntityName()); + final EClass eclass = ds.getEntityNameStrategy().toEClass(persistentClass.getEntityName()); if (eclass == null) { throw new HbMapperException("No eclass found for entityname: " + persistentClass.getEntityName()); @@ -184,54 +175,48 @@ public class EAVObjectTuplizer extends AbstractEntityTuplizer { /* * (non-Javadoc) * - * @see - * org.hibernate.tuple.AbstractEntityTuplizer#buildPropertyGetter(org.hibernate + * @see org.hibernate.tuple.AbstractEntityTuplizer#buildPropertyGetter(org.hibernate * .mapping.Property , org.hibernate.mapping.PersistentClass) */ @Override - protected Getter buildPropertyGetter(Property mappedProperty, - PersistentClass mappedEntity) { + protected Getter buildPropertyGetter(Property mappedProperty, PersistentClass mappedEntity) { if (mappedProperty.getName().equals("values")) { return mappedProperty.getGetter(EObjectImpl.class); } - return getPropertyAccessor(mappedProperty, mappedEntity).getGetter( - null, mappedProperty.getName()); + return getPropertyAccessor(mappedProperty, mappedEntity).getGetter(null, + mappedProperty.getName()); } /* * (non-Javadoc) * - * @see - * org.hibernate.tuple.AbstractEntityTuplizer#buildPropertySetter(org.hibernate + * @see org.hibernate.tuple.AbstractEntityTuplizer#buildPropertySetter(org.hibernate * .mapping.Property , org.hibernate.mapping.PersistentClass) */ @Override - protected Setter buildPropertySetter(Property mappedProperty, - PersistentClass mappedEntity) { + protected Setter buildPropertySetter(Property mappedProperty, PersistentClass mappedEntity) { if (mappedProperty.getName().equals("values")) { return mappedProperty.getSetter(EObjectImpl.class); } - return getPropertyAccessor(mappedProperty, mappedEntity).getSetter( - null, mappedProperty.getName()); + return getPropertyAccessor(mappedProperty, mappedEntity).getSetter(null, + mappedProperty.getName()); } /* * (non-Javadoc) * - * @seeorg.hibernate.tuple.AbstractEntityTuplizer#buildProxyFactory(org. - * hibernate.mapping. PersistentClass, org.hibernate.property.Getter, - * org.hibernate.property.Setter) + * @seeorg.hibernate.tuple.AbstractEntityTuplizer#buildProxyFactory(org. hibernate.mapping. + * PersistentClass, org.hibernate.property.Getter, org.hibernate.property.Setter) */ @Override - protected ProxyFactory buildProxyFactory(PersistentClass persistentClass, - Getter idGetter, Setter idSetter) { + protected ProxyFactory buildProxyFactory(PersistentClass persistentClass, Getter idGetter, + Setter idSetter) { if (persistentClass.getClassName() == null) { // an entity, no proxy return null; } final HbDataStore ds = HbHelper.INSTANCE.getDataStore(persistentClass); - final EClass eclass = ds.getEntityNameStrategy().toEClass( - persistentClass.getEntityName()); + final EClass eclass = ds.getEntityNameStrategy().toEClass(persistentClass.getEntityName()); if (eclass == null) { throw new HbMapperException("No eclass found for entityname: " + persistentClass.getEntityName()); @@ -267,29 +252,21 @@ public class EAVObjectTuplizer extends AbstractEntityTuplizer { } // get the idgettters/setters - final Method theIdGetterMethod = idGetter == null ? null : idGetter - .getMethod(); - final Method theIdSetterMethod = idSetter == null ? null : idSetter - .getMethod(); - - final Method proxyGetIdentifierMethod = theIdGetterMethod == null - || pInterface == null ? null : ReflectHelper.getMethod( - pInterface, theIdGetterMethod); - final Method proxySetIdentifierMethod = theIdSetterMethod == null - || pInterface == null ? null : ReflectHelper.getMethod( - pInterface, theIdSetterMethod); - - ProxyFactory pf = Environment.getBytecodeProvider() - .getProxyFactoryFactory().buildProxyFactory(); + final Method theIdGetterMethod = idGetter == null ? null : idGetter.getMethod(); + final Method theIdSetterMethod = idSetter == null ? null : idSetter.getMethod(); + + final Method proxyGetIdentifierMethod = theIdGetterMethod == null || pInterface == null ? null + : ReflectHelper.getMethod(pInterface, theIdGetterMethod); + final Method proxySetIdentifierMethod = theIdSetterMethod == null || pInterface == null ? null + : ReflectHelper.getMethod(pInterface, theIdSetterMethod); + + ProxyFactory pf = Environment.getBytecodeProvider().getProxyFactoryFactory() + .buildProxyFactory(); try { - pf.postInstantiate( - getEntityName(), - mappedClass, - proxyInterfaces, - proxyGetIdentifierMethod, + pf.postInstantiate(getEntityName(), mappedClass, proxyInterfaces, proxyGetIdentifierMethod, proxySetIdentifierMethod, - persistentClass.hasEmbeddedIdentifier() ? (CompositeType) persistentClass - .getIdentifier().getType() : null); + persistentClass.hasEmbeddedIdentifier() ? (CompositeType) persistentClass.getIdentifier() + .getType() : null); } catch (HbStoreException e) { log.warn("could not create proxy factory for:" + getEntityName(), e); pf = null; @@ -334,11 +311,9 @@ public class EAVObjectTuplizer extends AbstractEntityTuplizer { } /** Returns the correct accessor on the basis of the type of property */ - protected PropertyAccessor getPropertyAccessor(Property mappedProperty, - PersistentClass pc) { + protected PropertyAccessor getPropertyAccessor(Property mappedProperty, PersistentClass pc) { final HbDataStore ds = HbHelper.INSTANCE.getDataStore(pc); - return HbUtil.getPropertyAccessor(mappedProperty, ds, - pc.getEntityName(), null); + return HbUtil.getPropertyAccessor(mappedProperty, ds, pc.getEntityName(), null); } @Override @@ -360,8 +335,8 @@ public class EAVObjectTuplizer extends AbstractEntityTuplizer { } @Override - protected ProxyFactory buildProxyFactory(EntityBinding mappingInfo, - Getter idGetter, Setter idSetter) { + protected ProxyFactory buildProxyFactory(EntityBinding mappingInfo, Getter idGetter, + Setter idSetter) { // TODO Auto-generated method stub return null; } diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVPropertyHandler.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVPropertyHandler.java index 738ebafe2..914960f34 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVPropertyHandler.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVPropertyHandler.java @@ -38,8 +38,7 @@ import org.hibernate.property.Setter; * @version $Revision: 1.11 $ */ @SuppressWarnings("unchecked") -public class EAVPropertyHandler implements Getter, Setter, PropertyAccessor, - ExtensionPoint { +public class EAVPropertyHandler implements Getter, Setter, PropertyAccessor, ExtensionPoint { private static final long serialVersionUID = -3712366809398761331L; @@ -48,24 +47,20 @@ public class EAVPropertyHandler implements Getter, Setter, PropertyAccessor, /* * (non-Javadoc) * - * @see org.hibernate.property.PropertyAccessor#getGetter(java.lang.Class, - * java.lang.String) + * @see org.hibernate.property.PropertyAccessor#getGetter(java.lang.Class, java.lang.String) */ @SuppressWarnings("rawtypes") - public Getter getGetter(Class theClass, String propertyName) - throws PropertyNotFoundException { + public Getter getGetter(Class theClass, String propertyName) throws PropertyNotFoundException { return this; } /* * (non-Javadoc) * - * @see org.hibernate.property.PropertyAccessor#getSetter(java.lang.Class, - * java.lang.String) + * @see org.hibernate.property.PropertyAccessor#getSetter(java.lang.Class, java.lang.String) */ @SuppressWarnings("rawtypes") - public Setter getSetter(Class theClass, String propertyName) - throws PropertyNotFoundException { + public Setter getSetter(Class theClass, String propertyName) throws PropertyNotFoundException { return this; } @@ -98,23 +93,23 @@ public class EAVPropertyHandler implements Getter, Setter, PropertyAccessor, /* * (non-Javadoc) * - * @see org.hibernate.property.Getter#getForInsert(java.lang.Object, - * java.util.Map, org.hibernate.engine.SessionImplementor) + * @see org.hibernate.property.Getter#getForInsert(java.lang.Object, java.util.Map, + * org.hibernate.engine.SessionImplementor) */ @SuppressWarnings("rawtypes") - public Object getForInsert(Object owner, Map mergeMap, - SessionImplementor session) throws HibernateException { + public Object getForInsert(Object owner, Map mergeMap, SessionImplementor session) + throws HibernateException { return get(owner); } /* * (non-Javadoc) * - * @see org.hibernate.property.Setter#set(java.lang.Object, - * java.lang.Object, org.hibernate.engine.SessionFactoryImplementor) + * @see org.hibernate.property.Setter#set(java.lang.Object, java.lang.Object, + * org.hibernate.engine.SessionFactoryImplementor) */ - public void set(Object target, Object value, - SessionFactoryImplementor factory) throws HibernateException { + public void set(Object target, Object value, SessionFactoryImplementor factory) + throws HibernateException { final EObject eOwner = (EObject) target; for (Adapter adapter : eOwner.eAdapters()) { if (adapter instanceof EAVObjectAdapter) { @@ -170,14 +165,11 @@ public class EAVPropertyHandler implements Getter, Setter, PropertyAccessor, private List<EAVValueHolder> createValueList(EObject target) { final List<EAVValueHolder> valueHolders = new ArrayList<EAVValueHolder>(); - for (EStructuralFeature eFeature : target.eClass() - .getEAllStructuralFeatures()) { - if (eFeature.isDerived() || eFeature.isTransient() - || eFeature.isVolatile()) { + for (EStructuralFeature eFeature : target.eClass().getEAllStructuralFeatures()) { + if (eFeature.isDerived() || eFeature.isTransient() || eFeature.isVolatile()) { continue; } - final EAVValueHolder valueHolder = EAVValueHolder.create(target, - eFeature, hbDataStore); + final EAVValueHolder valueHolder = EAVValueHolder.create(target, eFeature, hbDataStore); valueHolder.set(target.eGet(eFeature)); if (eFeature.isUnsettable()) { valueHolder.setValueIsSet(target.eIsSet(eFeature)); @@ -230,8 +222,7 @@ public class EAVPropertyHandler implements Getter, Setter, PropertyAccessor, } public void notifyChanged(Notification notification) { - final EStructuralFeature eFeature = (EStructuralFeature) notification - .getFeature(); + final EStructuralFeature eFeature = (EStructuralFeature) notification.getFeature(); final EAVValueHolder valueHolder = getValueHolder(eFeature); EAVMultiValueHolder multiValueHolder = null; @@ -247,8 +238,7 @@ public class EAVPropertyHandler implements Getter, Setter, PropertyAccessor, return; } - final Object currentEMFValue = valueHolder.getOwner() - .eGet(eFeature); + final Object currentEMFValue = valueHolder.getOwner().eGet(eFeature); if (currentEMFValue instanceof EAVDelegatingEcoreEList<?>) { // this type of list manages the changes directly return; @@ -267,12 +257,11 @@ public class EAVPropertyHandler implements Getter, Setter, PropertyAccessor, case Notification.ADD: { if (notification.getPosition() != Notification.NO_INDEX) { repairFromIndex = notification.getPosition(); - list.add(notification.getPosition(), multiValueHolder - .getElement(notification.getNewValue())); + list.add(notification.getPosition(), + multiValueHolder.getElement(notification.getNewValue())); } else { repairFromIndex = list.size(); - list.add(multiValueHolder.getElement(notification - .getNewValue())); + list.add(multiValueHolder.getElement(notification.getNewValue())); } } break; @@ -320,8 +309,7 @@ public class EAVPropertyHandler implements Getter, Setter, PropertyAccessor, if (removeIndex == Notification.NO_INDEX) { for (Object o : list) { final EAVValueHolder elemValue = (EAVValueHolder) o; - if (elemValue.getValue() != null - && oldValue != null + if (elemValue.getValue() != null && oldValue != null && elemValue.getValue().equals(oldValue)) { removeIndex = list.indexOf(o); break; @@ -343,8 +331,7 @@ public class EAVPropertyHandler implements Getter, Setter, PropertyAccessor, break; case Notification.MOVE: if (list != null) { - final int oldPosition = (Integer) notification - .getOldValue(); + final int oldPosition = (Integer) notification.getOldValue(); final int newPosition = notification.getPosition(); final Object o = list.remove(oldPosition); list.add(newPosition, o); @@ -358,9 +345,8 @@ public class EAVPropertyHandler implements Getter, Setter, PropertyAccessor, case Notification.SET: if (eFeature.isMany()) { final int position = notification.getPosition(); - final EAVValueHolder elementValueHolder = (EAVValueHolder) list - .set(position, multiValueHolder - .getElement(notification.getNewValue())); + final EAVValueHolder elementValueHolder = (EAVValueHolder) list.set(position, + multiValueHolder.getElement(notification.getNewValue())); repairFromIndex = notification.getPosition(); if (elementValueHolder != null) { elementValueHolder.setListIndex(0); @@ -383,14 +369,12 @@ public class EAVPropertyHandler implements Getter, Setter, PropertyAccessor, if (o instanceof EObject) { StoreUtil.setSyntheticListIndex(eFeature, o, index++); - StoreUtil.setSyntheticListOwner(eFeature, o, - notification.getNotifier()); + StoreUtil.setSyntheticListOwner(eFeature, o, notification.getNotifier()); } if (o instanceof EAVValueHolder) { final EAVValueHolder eavValueHolder = (EAVValueHolder) o; eavValueHolder.setListIndex(index++); - eavValueHolder - .setValueOwner((EAVMultiValueHolder) valueHolder); + eavValueHolder.setValueOwner((EAVMultiValueHolder) valueHolder); } } } diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVSingleEAttributeValueHolder.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVSingleEAttributeValueHolder.java index af87962d3..e4ceab35c 100644 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVSingleEAttributeValueHolder.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVSingleEAttributeValueHolder.java @@ -77,8 +77,7 @@ public class EAVSingleEAttributeValueHolder extends EAVValueHolder { // do type specific handling final boolean isBlob = value instanceof byte[] || (value instanceof String && isClob(getEStructuralFeature())); - final EDataType eDataType = (EDataType) getEStructuralFeature() - .getEType(); + final EDataType eDataType = (EDataType) getEStructuralFeature().getEType(); final EFactory eFactory = eDataType.getEPackage().getEFactoryInstance(); if (!isBlob) { typeNeutralValue = eFactory.convertToString(eDataType, value); @@ -103,8 +102,7 @@ public class EAVSingleEAttributeValueHolder extends EAVValueHolder { if (value instanceof BigDecimal) { final BigDecimal bdValue = (BigDecimal) value; if (bdValue.precision() > MAX_PRECISION) { - final MathContext mathContext = new MathContext( - MAX_PRECISION); + final MathContext mathContext = new MathContext(MAX_PRECISION); numericValue = bdValue.round(mathContext); } else { numericValue = bdValue; @@ -113,12 +111,12 @@ public class EAVSingleEAttributeValueHolder extends EAVValueHolder { longValue = ((BigInteger) value).longValue(); } else if (value instanceof Double || value instanceof Float) { doubleValue = ((Number) value).doubleValue(); - } else if (value instanceof Integer || value instanceof Long - || value instanceof Short || value instanceof Byte) { + } else if (value instanceof Integer || value instanceof Long || value instanceof Short + || value instanceof Byte) { longValue = ((Number) value).longValue(); } else { - throw new UnsupportedOperationException("Primitive type " - + value.getClass() + " not supported here."); + throw new UnsupportedOperationException("Primitive type " + value.getClass() + + " not supported here."); } } } @@ -129,12 +127,9 @@ public class EAVSingleEAttributeValueHolder extends EAVValueHolder { } else if (objectValue == null && textValue != null) { objectValue = textValue.getTextValue(); } else if (objectValue == null && typeNeutralValue != null) { - final EDataType eDataType = (EDataType) getEStructuralFeature() - .getEType(); - final EFactory eFactory = eDataType.getEPackage() - .getEFactoryInstance(); - objectValue = eFactory - .createFromString(eDataType, typeNeutralValue); + final EDataType eDataType = (EDataType) getEStructuralFeature().getEType(); + final EFactory eFactory = eDataType.getEPackage().getEFactoryInstance(); + objectValue = eFactory.createFromString(eDataType, typeNeutralValue); } return objectValue; @@ -219,16 +214,16 @@ public class EAVSingleEAttributeValueHolder extends EAVValueHolder { private boolean isClob(EStructuralFeature eFeature) { final EAttribute eAttribute = (EAttribute) eFeature; try { - final PAnnotatedEAttribute paEAttribute = getHbDataStore() - .getPaModel().getPAnnotated(eAttribute); + final PAnnotatedEAttribute paEAttribute = getHbDataStore().getPaModel().getPAnnotated( + eAttribute); if (paEAttribute == null) { return false; } if (paEAttribute.getLob() != null) { return true; } - final PAnnotatedEDataType paDataType = getHbDataStore() - .getPaModel().getPAnnotated(eAttribute.getEAttributeType()); + final PAnnotatedEDataType paDataType = getHbDataStore().getPaModel().getPAnnotated( + eAttribute.getEAttributeType()); if (paDataType == null) { return false; } @@ -239,13 +234,11 @@ public class EAVSingleEAttributeValueHolder extends EAVValueHolder { } } - protected static boolean isFeatureExtraLazy(HbDataStore hbDataStore, - EStructuralFeature eFeature) { + protected static boolean isFeatureExtraLazy(HbDataStore hbDataStore, EStructuralFeature eFeature) { if (hbDataStore.getPersistenceOptions().isFetchAssociationExtraLazy()) { return true; } - final PAnnotatedEStructuralFeature paFeature = hbDataStore.getPaModel() - .getPAnnotated(eFeature); + final PAnnotatedEStructuralFeature paFeature = hbDataStore.getPaModel().getPAnnotated(eFeature); if (paFeature.getOneToMany() != null && paFeature.getOneToMany().getFetch().equals(FetchType.EXTRA)) { return Boolean.TRUE; diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVSingleEReferenceValueHolder.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVSingleEReferenceValueHolder.java index 162d98d77..379687cdd 100644 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVSingleEReferenceValueHolder.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVSingleEReferenceValueHolder.java @@ -44,8 +44,7 @@ public class EAVSingleEReferenceValueHolder extends EAVValueHolder { public void setValueInOwner(InternalEObject owner) { final Object curValue = owner.eGet(getEStructuralFeature()); - final int featureId = owner.eClass().getFeatureID( - getEStructuralFeature()); + final int featureId = owner.eClass().getFeatureID(getEStructuralFeature()); if (curValue == referenceValue) { // note that == works fine if the // curValue and value have been read in the same jvm. @@ -53,26 +52,23 @@ public class EAVSingleEReferenceValueHolder extends EAVValueHolder { } if (getEReference().getEOpposite() != null - || (owner instanceof DynamicEObjectImpl && getEReference() - .isContainment())) { + || (owner instanceof DynamicEObjectImpl && getEReference().isContainment())) { // these are handled a bit differently because if (referenceValue == null) { // remove // Note that the eInverseRemove is called on the target itself // and the value is passed // therefore the eReference featureid is passed and not the // opposite - final NotificationChain nots = ((InternalEObject) owner) - .eInverseRemove((InternalEObject) curValue, featureId, - getEReference().getEType().getInstanceClass(), - null); + final NotificationChain nots = ((InternalEObject) owner).eInverseRemove( + (InternalEObject) curValue, featureId, getEReference().getEType().getInstanceClass(), + null); if (nots != null) { nots.dispatch(); } } else { - final NotificationChain nots = ((InternalEObject) owner) - .eInverseAdd((InternalEObject) referenceValue, - featureId, getEReference().getEType() - .getInstanceClass(), null); + final NotificationChain nots = ((InternalEObject) owner).eInverseAdd( + (InternalEObject) referenceValue, featureId, getEReference().getEType() + .getInstanceClass(), null); if (nots != null) { nots.dispatch(); } @@ -93,7 +89,7 @@ public class EAVSingleEReferenceValueHolder extends EAVValueHolder { } else { setEavObjectReference(null); } - + } public Object getValue() { @@ -122,14 +118,12 @@ public class EAVSingleEReferenceValueHolder extends EAVValueHolder { private boolean isEAVMapped(EClass eClass) { try { - final PAnnotatedEClass paClass = getHbDataStore().getPaModel() - .getPAnnotated(eClass); + final PAnnotatedEClass paClass = getHbDataStore().getPaModel().getPAnnotated(eClass); if (paClass.getEntity() == null) { return false; } final String entityName = paClass.getEntity().getName(); - final PersistentClass pc = getHbDataStore().getPersistentClass( - entityName); + final PersistentClass pc = getHbDataStore().getPersistentClass(entityName); return HbUtil.isEAVMapped(pc); } catch (IllegalArgumentException e) { // not mapped diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVSingleNonContainmentEReferenceValueHolder.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVSingleNonContainmentEReferenceValueHolder.java index 143a61dc7..009d7f5b8 100644 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVSingleNonContainmentEReferenceValueHolder.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVSingleNonContainmentEReferenceValueHolder.java @@ -17,7 +17,6 @@ package org.eclipse.emf.teneo.hibernate.mapping.eav; - /** * Stores a single EReference value when the EReference is non containment. * diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVTuplizer.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVTuplizer.java index c1325ee8c..b4e1e3b5e 100644 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVTuplizer.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVTuplizer.java @@ -29,7 +29,8 @@ import org.hibernate.tuple.entity.EntityMetamodel; import org.hibernate.tuple.entity.PojoEntityTuplizer; /** - * Tuplizer created to work around this issue: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4078 + * Tuplizer created to work around this issue: + * http://opensource.atlassian.com/projects/hibernate/browse/HHH-4078 * * @author <a href="mtaal@elver.org">Martin Taal</a> */ @@ -46,7 +47,8 @@ public class EAVTuplizer extends PojoEntityTuplizer { /** * {@inheritDoc} */ - public String determineConcreteSubclassEntityName(Object entityInstance, SessionFactoryImplementor factory) { + public String determineConcreteSubclassEntityName(Object entityInstance, + SessionFactoryImplementor factory) { final Class<?> concreteEntityClass = entityInstance.getClass(); if (concreteEntityClass == getMappedClass()) { return getEntityName(); @@ -58,8 +60,9 @@ public class EAVTuplizer extends PojoEntityTuplizer { return pc.getEntityName(); } } - throw new HibernateException("Unable to resolve entity name from Class [" + concreteEntityClass.getName() - + "]" + " expected instance/subclass of [" + getEntityName() + "]"); + throw new HibernateException("Unable to resolve entity name from Class [" + + concreteEntityClass.getName() + "]" + " expected instance/subclass of [" + + getEntityName() + "]"); } } @@ -67,21 +70,21 @@ public class EAVTuplizer extends PojoEntityTuplizer { public void setPropertyValues(Object entity, Object[] values) throws HibernateException { boolean setAll = !getEntityMetamodel().hasLazyProperties(); - for ( int j = 0; j < getEntityMetamodel().getPropertySpan(); j++ ) { - if ( setAll || values[j] != LazyPropertyInitializer.UNFETCHED_PROPERTY ) { + for (int j = 0; j < getEntityMetamodel().getPropertySpan(); j++) { + if (setAll || values[j] != LazyPropertyInitializer.UNFETCHED_PROPERTY) { if (values[j] instanceof PersistentList) { - final PersistentList persistentList = (PersistentList)values[j]; + final PersistentList persistentList = (PersistentList) values[j]; if (persistentList.getOwner() == null) { persistentList.setOwner(entity); } } - setters[j].set( entity, values[j], getFactory() ); + setters[j].set(entity, values[j], getFactory()); } } } @Override protected Instantiator buildInstantiator(PersistentClass persistentClass) { - return new EAVValueInstantiator( persistentClass, null ); + return new EAVValueInstantiator(persistentClass, null); } }
\ No newline at end of file diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVValueHolder.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVValueHolder.java index e30314920..956359c2b 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVValueHolder.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVValueHolder.java @@ -27,18 +27,17 @@ import org.eclipse.emf.teneo.annotations.pannotation.FetchType; import org.eclipse.emf.teneo.hibernate.HbDataStore; /** - * The base class of the value stored in an EAV schema. The value in an EAV - * schema is both the type (the EStructuralFeature) and its value. The following - * different types of values can be identified: + * The base class of the value stored in an EAV schema. The value in an EAV schema is both the type + * (the EStructuralFeature) and its value. The following different types of values can be + * identified: * <ul> * <li>EAttribute: a single primitive value</li> - * <li>EReference: a single reference to another object, containment or - * non-containment</li> + * <li>EReference: a single reference to another object, containment or non-containment</li> * <li>MultiEAttribute: a multi-occurrence EAttribute</li> * <li>MultiEReference: a multi-occurrence EReference</li> * </ul> - * In addition there is the FeatureMap and Map support which needs to be - * handled. In EMF both are lists with EAttributes. + * In addition there is the FeatureMap and Map support which needs to be handled. In EMF both are + * lists with EAttributes. * * The above structure is reflected in the EAVValueHolder class hierarchy. * @@ -52,8 +51,8 @@ public abstract class EAVValueHolder { protected static Integer NOT_NULL_VALUE = new Integer(1); - public static EAVValueHolder create(EObject owner, - EStructuralFeature eFeature, HbDataStore hbDataStore) { + public static EAVValueHolder create(EObject owner, EStructuralFeature eFeature, + HbDataStore hbDataStore) { final EAVValueHolder valueHolder; if (eFeature instanceof EReference) { final EReference eReference = (EReference) eFeature; @@ -97,17 +96,15 @@ public abstract class EAVValueHolder { return valueHolder; } - protected static boolean isFeatureExtraLazy(HbDataStore hbDataStore, - EStructuralFeature eFeature) { + protected static boolean isFeatureExtraLazy(HbDataStore hbDataStore, EStructuralFeature eFeature) { if (hbDataStore.getPersistenceOptions().isFetchAssociationExtraLazy()) { return true; } try { - final PAnnotatedEStructuralFeature paFeature = hbDataStore - .getPaModel().getPAnnotated(eFeature); + final PAnnotatedEStructuralFeature paFeature = hbDataStore.getPaModel().getPAnnotated( + eFeature); if (paFeature.getOneToMany() != null - && paFeature.getOneToMany().getFetch().equals( - FetchType.EXTRA)) { + && paFeature.getOneToMany().getFetch().equals(FetchType.EXTRA)) { return Boolean.TRUE; } return false; @@ -199,8 +196,7 @@ public abstract class EAVValueHolder { return NOT_NULL_VALUE; } // if not required then the not-value is set always - if (!getEStructuralFeature().isRequired() - || getEStructuralFeature().isUnsettable()) { + if (!getEStructuralFeature().isRequired() || getEStructuralFeature().isUnsettable()) { return NOT_NULL_VALUE; } return mandatoryValue; diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVValueInstantiator.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVValueInstantiator.java index 040868d0a..71df01102 100644 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVValueInstantiator.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/eav/EAVValueInstantiator.java @@ -35,21 +35,23 @@ public class EAVValueInstantiator extends PojoInstantiator { private static final long serialVersionUID = 6946442685247491904L; private HbDataStore hbDataStore; - - public EAVValueInstantiator(Component component, ReflectionOptimizer.InstantiationOptimizer optimizer) { + + public EAVValueInstantiator(Component component, + ReflectionOptimizer.InstantiationOptimizer optimizer) { super(component, optimizer); hbDataStore = HbHelper.INSTANCE.getDataStore(component); } - public EAVValueInstantiator(PersistentClass persistentClass, ReflectionOptimizer.InstantiationOptimizer optimizer) { + public EAVValueInstantiator(PersistentClass persistentClass, + ReflectionOptimizer.InstantiationOptimizer optimizer) { super(persistentClass, optimizer); hbDataStore = HbHelper.INSTANCE.getDataStore(persistentClass); } - + public Object instantiate() { final Object object = super.instantiate(); if (object instanceof EAVValueHolder) { - final EAVValueHolder valueHolder = (EAVValueHolder)object; + final EAVValueHolder valueHolder = (EAVValueHolder) object; valueHolder.setHbDataStore(hbDataStore); } return object; diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/econtainer/EContainerAccessor.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/econtainer/EContainerAccessor.java index 65da5f6c9..0018e3502 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/econtainer/EContainerAccessor.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/econtainer/EContainerAccessor.java @@ -41,7 +41,8 @@ public class EContainerAccessor implements PropertyAccessor, ExtensionPoint, Ext */ @SuppressWarnings("rawtypes") public Getter getGetter(Class theClass, String propertyName) throws PropertyNotFoundException { - final EContainerPropertyHandler handler = extensionManager.getExtension(EContainerPropertyHandler.class); + final EContainerPropertyHandler handler = extensionManager + .getExtension(EContainerPropertyHandler.class); handler.initialize(propertyName); return handler; } @@ -53,14 +54,15 @@ public class EContainerAccessor implements PropertyAccessor, ExtensionPoint, Ext */ @SuppressWarnings("rawtypes") public Setter getSetter(Class theClass, String propertyName) throws PropertyNotFoundException { - final EContainerPropertyHandler handler = extensionManager.getExtension(EContainerPropertyHandler.class); + final EContainerPropertyHandler handler = extensionManager + .getExtension(EContainerPropertyHandler.class); handler.initialize(propertyName); return handler; } /** * @param extensionManager - * the extensionManager to set + * the extensionManager to set */ public void setExtensionManager(ExtensionManager extensionManager) { this.extensionManager = extensionManager; diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/econtainer/EContainerFeatureIDAccessor.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/econtainer/EContainerFeatureIDAccessor.java index fbc6a7a31..2b35c83d3 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/econtainer/EContainerFeatureIDAccessor.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/econtainer/EContainerFeatureIDAccessor.java @@ -30,7 +30,8 @@ import org.hibernate.property.Setter; * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> * @version $Revision: 1.6 $ */ -public class EContainerFeatureIDAccessor implements PropertyAccessor, ExtensionPoint, ExtensionManagerAware { +public class EContainerFeatureIDAccessor implements PropertyAccessor, ExtensionPoint, + ExtensionManagerAware { private ExtensionManager extensionManager; @@ -41,8 +42,8 @@ public class EContainerFeatureIDAccessor implements PropertyAccessor, ExtensionP */ @SuppressWarnings("rawtypes") public Getter getGetter(Class theClass, String propertyName) throws PropertyNotFoundException { - final EContainerFeatureIDPropertyHandler handler = - extensionManager.getExtension(EContainerFeatureIDPropertyHandler.class); + final EContainerFeatureIDPropertyHandler handler = extensionManager + .getExtension(EContainerFeatureIDPropertyHandler.class); handler.initialize(propertyName); return handler; } @@ -54,8 +55,8 @@ public class EContainerFeatureIDAccessor implements PropertyAccessor, ExtensionP */ @SuppressWarnings("rawtypes") public Setter getSetter(Class theClass, String propertyName) throws PropertyNotFoundException { - final EContainerFeatureIDPropertyHandler handler = - extensionManager.getExtension(EContainerFeatureIDPropertyHandler.class); + final EContainerFeatureIDPropertyHandler handler = extensionManager + .getExtension(EContainerFeatureIDPropertyHandler.class); handler.initialize(propertyName); return handler; } @@ -63,7 +64,8 @@ public class EContainerFeatureIDAccessor implements PropertyAccessor, ExtensionP /* * (non-Javadoc) * - * @see org.eclipse.emf.teneo.extension.ExtensionManagerAware#setExtensionManager(org.eclipse.emf.teneo.extension.ExtensionManager) + * @see org.eclipse.emf.teneo.extension.ExtensionManagerAware#setExtensionManager + * (org.eclipse.emf.teneo.extension.ExtensionManager) */ public void setExtensionManager(ExtensionManager extensionManager) { this.extensionManager = extensionManager; diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/econtainer/EContainerFeatureIDPropertyHandler.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/econtainer/EContainerFeatureIDPropertyHandler.java index f04ac569e..8ab14b011 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/econtainer/EContainerFeatureIDPropertyHandler.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/econtainer/EContainerFeatureIDPropertyHandler.java @@ -41,16 +41,14 @@ import org.hibernate.property.Setter; * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> * @version $Revision: 1.10 $ */ -public class EContainerFeatureIDPropertyHandler implements Getter, Setter, - ExtensionPoint { +public class EContainerFeatureIDPropertyHandler implements Getter, Setter, ExtensionPoint { /** * Generated Serial ID */ private static final long serialVersionUID = -7360171596936226424L; /** The logger */ - private static Log log = LogFactory - .getLog(EContainerFeatureIDPropertyHandler.class); + private static Log log = LogFactory.getLog(EContainerFeatureIDPropertyHandler.class); /** The javafield of the eContainer */ private Field ecField; @@ -93,25 +91,22 @@ public class EContainerFeatureIDPropertyHandler implements Getter, Setter, /* * (non-Javadoc) * - * @see org.hibernate.property.Setter#set(java.lang.Object, - * java.lang.Object, org.hibernate.engine.SessionFactoryImplementor) + * @see org.hibernate.property.Setter#set(java.lang.Object, java.lang.Object, + * org.hibernate.engine.SessionFactoryImplementor) */ - public void set(Object target, Object value, - SessionFactoryImplementor factory) throws HibernateException { + public void set(Object target, Object value, SessionFactoryImplementor factory) + throws HibernateException { if (target instanceof MinimalEObjectImpl) { // TODO: externalize this - FieldUtil.callMethod(target, "eBasicSetContainerFeatureID", - new Object[] { value }); + FieldUtil.callMethod(target, "eBasicSetContainerFeatureID", new Object[] { value }); } else { assert (target instanceof EObjectImpl); assert (value instanceof Integer); try { ecField.set(target, value); } catch (Exception e) { - throw new HbMapperException( - "Exception when setting eContainerFeatureID for: " - + target.getClass().getName() + " to value: " - + value, e); + throw new HbMapperException("Exception when setting eContainerFeatureID for: " + + target.getClass().getName() + " to value: " + value, e); } } } @@ -128,12 +123,12 @@ public class EContainerFeatureIDPropertyHandler implements Getter, Setter, /* * (non-Javadoc) * - * @see org.hibernate.property.Getter#getForInsert(java.lang.Object, - * java.util.Map, org.hibernate.engine.SessionImplementor) + * @see org.hibernate.property.Getter#getForInsert(java.lang.Object, java.util.Map, + * org.hibernate.engine.SessionImplementor) */ @SuppressWarnings("rawtypes") - public Object getForInsert(Object owner, Map mergeMap, - SessionImplementor session) throws HibernateException { + public Object getForInsert(Object owner, Map mergeMap, SessionImplementor session) + throws HibernateException { return new Integer(((BasicEObjectImpl) owner).eContainerFeatureID()); } diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/econtainer/EContainerFeatureIDUserType.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/econtainer/EContainerFeatureIDUserType.java index e79560a8d..e98fe0710 100644 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/econtainer/EContainerFeatureIDUserType.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/econtainer/EContainerFeatureIDUserType.java @@ -33,8 +33,8 @@ import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.usertype.UserType; /** - * Persists an EContainerFeatureID as a varchar which contains both the EClass of the container as the complete - * reference to the EFeature. + * Persists an EContainerFeatureID as a varchar which contains both the EClass of the container as + * the complete reference to the EFeature. * * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> * @version $Revision: 1.5 $ $Date: 2010/05/02 14:24:11 $ @@ -108,7 +108,8 @@ public class EContainerFeatureIDUserType implements UserType { return false; } - public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor sessionImplementor, Object owner) throws HibernateException, SQLException { + public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor sessionImplementor, + Object owner) throws HibernateException, SQLException { final String value = rs.getString(names[0]); if (rs.wasNull()) { return null; @@ -118,7 +119,8 @@ public class EContainerFeatureIDUserType implements UserType { return holder; } - public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor sessionImplementor) throws HibernateException, SQLException { + public void nullSafeSet(PreparedStatement st, Object value, int index, + SessionImplementor sessionImplementor) throws HibernateException, SQLException { if (value == null) { st.setNull(index, Types.VARCHAR); } else { @@ -151,7 +153,7 @@ public class EContainerFeatureIDUserType implements UserType { /** * @param feature - * the eFeature to set + * the eFeature to set */ public void setEFeature(EStructuralFeature feature) { eFeature = feature; @@ -186,7 +188,7 @@ public class EContainerFeatureIDUserType implements UserType { /** * @param class1 - * the eClass to set + * the eClass to set */ public void setEClass(EClass class1) { eClass = class1; diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/econtainer/EContainerPropertyHandler.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/econtainer/EContainerPropertyHandler.java index e82451ba7..ecc893a07 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/econtainer/EContainerPropertyHandler.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/econtainer/EContainerPropertyHandler.java @@ -44,8 +44,7 @@ import org.hibernate.property.Setter; * @version $Revision: 1.10 $ */ -public class EContainerPropertyHandler implements Getter, Setter, - ExtensionPoint { +public class EContainerPropertyHandler implements Getter, Setter, ExtensionPoint { /** * Generated Serial Version UID */ @@ -86,37 +85,34 @@ public class EContainerPropertyHandler implements Getter, Setter, /* * (non-Javadoc) * - * @see org.hibernate.property.Getter#getForInsert(java.lang.Object, - * java.util.Map, org.hibernate.engine.SessionImplementor) + * @see org.hibernate.property.Getter#getForInsert(java.lang.Object, java.util.Map, + * org.hibernate.engine.SessionImplementor) */ @SuppressWarnings("rawtypes") - public Object getForInsert(Object owner, Map mergeMap, - SessionImplementor session) throws HibernateException { + public Object getForInsert(Object owner, Map mergeMap, SessionImplementor session) + throws HibernateException { return ((EObject) owner).eContainer(); } /* * (non-Javadoc) * - * @see org.hibernate.property.Setter#set(java.lang.Object, - * java.lang.Object, org.hibernate.engine.SessionFactoryImplementor) + * @see org.hibernate.property.Setter#set(java.lang.Object, java.lang.Object, + * org.hibernate.engine.SessionFactoryImplementor) */ - public void set(Object target, Object value, - SessionFactoryImplementor factory) throws HibernateException { + public void set(Object target, Object value, SessionFactoryImplementor factory) + throws HibernateException { if (target instanceof MinimalEObjectImpl) { // TODO: externalize this - FieldUtil.callMethod(target, "eBasicSetContainer", - new Object[] { value }); + FieldUtil.callMethod(target, "eBasicSetContainer", new Object[] { value }); } else { AssertUtil.assertInstanceOfNotNull(target, InternalEObject.class); AssertUtil.assertInstanceOf(value, EObject.class); try { ecField.set(target, value); } catch (Exception e) { - throw new HbMapperException( - "Exception when setting econtainer for: " - + target.getClass().getName() + " to value: " - + value, e); + throw new HbMapperException("Exception when setting econtainer for: " + + target.getClass().getName() + " to value: " + value, e); } } } diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/econtainer/EContainerUserType.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/econtainer/EContainerUserType.java index 441b0a5a5..b34742d3e 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/econtainer/EContainerUserType.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/econtainer/EContainerUserType.java @@ -58,8 +58,7 @@ import org.hibernate.usertype.CompositeUserType; * @version $Revision: 1.13 $ $Date: 2010/11/12 09:33:33 $ */ -public class EContainerUserType extends AbstractType implements - CompositeUserType, AssociationType { +public class EContainerUserType extends AbstractType implements CompositeUserType, AssociationType { /** * Serial version id */ @@ -69,16 +68,14 @@ public class EContainerUserType extends AbstractType implements private static final String ENCODING_SEPARATOR = ";"; /** The property names */ - private static final String[] propertyNames = new String[] { - "containerclass", "containerid" }; + private static final String[] propertyNames = new String[] { "containerclass", "containerid" }; /** The property types (two strings) */ - private static final Type[] propertyTypes = new Type[] { - StandardBasicTypes.STRING, StandardBasicTypes.STRING }; + private static final Type[] propertyTypes = new Type[] { StandardBasicTypes.STRING, + StandardBasicTypes.STRING }; /** The sql types */ - private static final int[] sqlTypes = new int[] { Types.VARCHAR, - Types.VARCHAR }; + private static final int[] sqlTypes = new int[] { Types.VARCHAR, Types.VARCHAR }; /** HashTable with cached constructors */ private final ConcurrentHashMap<String, Constructor<?>> constructorCache = new ConcurrentHashMap<String, Constructor<?>>(); @@ -87,13 +84,11 @@ public class EContainerUserType extends AbstractType implements private final ConcurrentHashMap<String, Type> identifierTypeCache = new ConcurrentHashMap<String, Type>(); /** - * Abstract method from super class, currently does not really print - * anything meaningfull + * Abstract method from super class, currently does not really print anything meaningfull */ - public String toLoggableString(Object value, - SessionFactoryImplementor factory) throws HibernateException { - return (value != null ? "EContainer: " + value.getClass().getName() - : "EContainer null value"); + public String toLoggableString(Object value, SessionFactoryImplementor factory) + throws HibernateException { + return (value != null ? "EContainer: " + value.getClass().getName() : "EContainer null value"); } /** The generic class returned (nl. Object) */ @@ -102,14 +97,13 @@ public class EContainerUserType extends AbstractType implements } /** Just returns passed value */ - public Object deepCopy(Object value, EntityMode entityMode, - SessionFactoryImplementor factory) throws HibernateException { + public Object deepCopy(Object value, EntityMode entityMode, SessionFactoryImplementor factory) + throws HibernateException { return value; } /** Not supported */ - public Object fromXMLNode(Node xml, Mapping factory) - throws HibernateException { + public Object fromXMLNode(Node xml, Mapping factory) throws HibernateException { throw new UnsupportedOperationException("not supported for econtainer"); } @@ -124,14 +118,13 @@ public class EContainerUserType extends AbstractType implements } /** Does nothing */ - public boolean isDirty(Object old, Object current, boolean[] checkable, - SessionImplementor session) throws HibernateException { + public boolean isDirty(Object old, Object current, boolean[] checkable, SessionImplementor session) + throws HibernateException { return isDirty(old, current, session); } /** Not supported */ - public Object nullSafeGet(ResultSet rs, String name, - SessionImplementor session, Object owner) + public Object nullSafeGet(ResultSet rs, String name, SessionImplementor session, Object owner) throws HibernateException, SQLException { throw new UnsupportedOperationException("not supported for econtainer"); } @@ -139,13 +132,11 @@ public class EContainerUserType extends AbstractType implements /* * (non-Javadoc) * - * @see org.hibernate.type.Type#nullSafeSet(java.sql.PreparedStatement, - * java.lang.Object, int, boolean[], - * org.hibernate.engine.SessionImplementor) + * @see org.hibernate.type.Type#nullSafeSet(java.sql.PreparedStatement, java.lang.Object, int, + * boolean[], org.hibernate.engine.SessionImplementor) */ - public void nullSafeSet(PreparedStatement st, Object value, int index, - boolean[] settable, SessionImplementor session) - throws HibernateException, SQLException { + public void nullSafeSet(PreparedStatement st, Object value, int index, boolean[] settable, + SessionImplementor session) throws HibernateException, SQLException { // TODO Auto-generated method stub if (settable == null || settable[0]) { nullSafeSet(st, value, index, session); @@ -159,15 +150,14 @@ public class EContainerUserType extends AbstractType implements * org.hibernate.engine.SessionImplementor, java.lang.Object, java.util.Map) */ @SuppressWarnings("rawtypes") - public Object replace(Object original, Object target, - SessionImplementor session, Object owner, Map copyCache) - throws HibernateException { + public Object replace(Object original, Object target, SessionImplementor session, Object owner, + Map copyCache) throws HibernateException { return replace(original, target, session, owner); } /** Not supported */ - public void setToXMLNode(Node node, Object value, - SessionFactoryImplementor factory) throws HibernateException { + public void setToXMLNode(Node node, Object value, SessionFactoryImplementor factory) + throws HibernateException { throw new UnsupportedOperationException("not supported for econtainer"); } @@ -177,8 +167,7 @@ public class EContainerUserType extends AbstractType implements } /** - * Returns array of boolean denoting which columns are null when the value - * is null + * Returns array of boolean denoting which columns are null when the value is null */ public boolean[] toColumnNullness(Object value, Mapping mapping) { boolean[] result = new boolean[getColumnSpan(mapping)]; @@ -191,9 +180,9 @@ public class EContainerUserType extends AbstractType implements } /** - * True as this is very similar to anytype, needed to return true because - * otherwise Hibernate would not recognize that the container object should - * be saved before this object and saving transient instance was called. + * True as this is very similar to anytype, needed to return true because otherwise Hibernate + * would not recognize that the container object should be saved before this object and saving + * transient instance was called. */ @Override public boolean isAnyType() { @@ -217,15 +206,13 @@ public class EContainerUserType extends AbstractType implements } /** Not supported */ - public String getAssociatedEntityName(SessionFactoryImplementor factory) - throws MappingException { + public String getAssociatedEntityName(SessionFactoryImplementor factory) throws MappingException { throw new UnsupportedOperationException( "Econtainer type is a generic type, no specific associated entity"); } /** Not supported */ - public Joinable getAssociatedJoinable(SessionFactoryImplementor factory) - throws MappingException { + public Joinable getAssociatedJoinable(SessionFactoryImplementor factory) throws MappingException { throw new UnsupportedOperationException( "Econtainer type is a generic type, no specific associated entity"); } @@ -242,8 +229,7 @@ public class EContainerUserType extends AbstractType implements /** Not supported */ @SuppressWarnings("rawtypes") - public String getOnCondition(String alias, - SessionFactoryImplementor factory, Map enabledFilters) + public String getOnCondition(String alias, SessionFactoryImplementor factory, Map enabledFilters) throws MappingException { throw new UnsupportedOperationException("not supported for econtainer"); } @@ -297,8 +283,8 @@ public class EContainerUserType extends AbstractType implements * Translates the serialized cached object to a real object */ @Override - public Object assemble(Serializable cached, SessionImplementor session, - Object owner) throws HibernateException { + public Object assemble(Serializable cached, SessionImplementor session, Object owner) + throws HibernateException { // palash: fix for ALL our teneo/ehcache woes!! // if cache is null, just return null, without guessing; hibernate is @@ -327,16 +313,16 @@ public class EContainerUserType extends AbstractType implements try { final String entityName = session.bestGuessEntityName(value); final Object idObject = getID(entityName, value, session); - return new ContainerPointer(getIdentifierType(entityName, session), - entityName, idObject.toString()); + return new ContainerPointer(getIdentifierType(entityName, session), entityName, + idObject.toString()); } catch (TransientObjectException toe) { return null; } } @Override - public Serializable disassemble(Object value, SessionImplementor session, - Object owner) throws HibernateException { + public Serializable disassemble(Object value, SessionImplementor session, Object owner) + throws HibernateException { return disassemble(value, session); } @@ -351,8 +337,7 @@ public class EContainerUserType extends AbstractType implements } /** Not supported */ - public Object getPropertyValue(Object component, int property) - throws HibernateException { + public Object getPropertyValue(Object component, int property) throws HibernateException { final Object container = ((InternalEObject) component).eContainer(); if (container == null) { return null; @@ -365,13 +350,12 @@ public class EContainerUserType extends AbstractType implements return IdentifierCacheHandler.getInstance().getID(container); } - throw new HbMapperException("Property: " + property - + " not supported in " + component.getClass().getName()); + throw new HbMapperException("Property: " + property + " not supported in " + + component.getClass().getName()); } /** Load the object on the basis of the data in the resultset */ - public Object nullSafeGet(ResultSet rs, String[] names, - SessionImplementor session, Object owner) + public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException { final String cc = rs.getString(names[0]); // container class if (cc == null) { @@ -382,14 +366,14 @@ public class EContainerUserType extends AbstractType implements return null; } - final Object obj = session.internalLoad(cc, - extractID(getIdentifierType(cc, session), idStr), false, false); + final Object obj = session.internalLoad(cc, extractID(getIdentifierType(cc, session), idStr), + false, false); return obj; } /** Set the data in the resultset */ - public void nullSafeSet(PreparedStatement st, Object value, int index, - SessionImplementor session) throws HibernateException, SQLException { + public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) + throws HibernateException, SQLException { if (value == null) { st.setNull(index, Types.VARCHAR); st.setNull(index + 1, Types.VARCHAR); @@ -397,10 +381,8 @@ public class EContainerUserType extends AbstractType implements // EObject eobj = (EObject) value; final String ename = session.bestGuessEntityName(value); st.setString(index, ename); - st.setString( - index + 1, - createIDString(getIdentifierType(ename, session), - getID(ename, value, session))); + st.setString(index + 1, + createIDString(getIdentifierType(ename, session), getID(ename, value, session))); } } @@ -413,8 +395,8 @@ public class EContainerUserType extends AbstractType implements return type; } - final Type identifierType = ((SessionImpl) session).getFactory() - .getClassMetadata(entityName).getIdentifierType(); + final Type identifierType = ((SessionImpl) session).getFactory().getClassMetadata(entityName) + .getIdentifierType(); identifierTypeCache.put(entityName, identifierType); return identifierType; } @@ -422,12 +404,11 @@ public class EContainerUserType extends AbstractType implements /* * (non-Javadoc) * - * @see org.hibernate.usertype.CompositeUserType#replace(java.lang.Object, - * java.lang.Object, org.hibernate.engine.SessionImplementor, - * java.lang.Object) + * @see org.hibernate.usertype.CompositeUserType#replace(java.lang.Object, java.lang.Object, + * org.hibernate.engine.SessionImplementor, java.lang.Object) */ - public Object replace(Object original, Object target, - SessionImplementor session, Object owner) throws HibernateException { + public Object replace(Object original, Object target, SessionImplementor session, Object owner) + throws HibernateException { if (original == null) { return null; } @@ -437,10 +418,8 @@ public class EContainerUserType extends AbstractType implements } /** Returns the id of the passed object */ - private Serializable getID(String entityName, Object value, - SessionImplementor session) { - Serializable result = ForeignKeys.getEntityIdentifierIfNotUnsaved( - entityName, value, session); + private Serializable getID(String entityName, Object value, SessionImplementor session) { + Serializable result = ForeignKeys.getEntityIdentifierIfNotUnsaved(entityName, value, session); if (result != null) { return result; @@ -451,8 +430,8 @@ public class EContainerUserType extends AbstractType implements /** * (non-Javadoc) * - * @see org.hibernate.usertype.CompositeUserType#setPropertyValue(java.lang.Object, - * int, java.lang.Object) + * @see org.hibernate.usertype.CompositeUserType#setPropertyValue(java.lang.Object, int, + * java.lang.Object) */ public void setPropertyValue(Object component, int property, Object value) throws HibernateException { @@ -468,25 +447,19 @@ public class EContainerUserType extends AbstractType implements } // for all other cases the classname is encoded into the field - final String className = idString.substring(0, - idString.indexOf(ENCODING_SEPARATOR)); - final String strValue = idString.substring(1 + idString - .indexOf(ENCODING_SEPARATOR)); + final String className = idString.substring(0, idString.indexOf(ENCODING_SEPARATOR)); + final String strValue = idString.substring(1 + idString.indexOf(ENCODING_SEPARATOR)); Constructor<?> constructor = constructorCache.get(className); if (constructor == null) { try { - final Class<?> clazz = ClassLoaderResolver - .classForName(className); - constructor = clazz - .getConstructor(new Class[] { String.class }); + final Class<?> clazz = ClassLoaderResolver.classForName(className); + constructor = clazz.getConstructor(new Class[] { String.class }); } catch (StoreClassLoadException e) { throw new HbMapperException("Class " + className + " not found"); } catch (NoSuchMethodException e) { - throw new HbMapperException( - "Class " - + className - + " does not have a constructor with a String parameter!"); + throw new HbMapperException("Class " + className + + " does not have a constructor with a String parameter!"); } } if (constructor == null) { @@ -495,17 +468,13 @@ public class EContainerUserType extends AbstractType implements } try { - return (Serializable) constructor - .newInstance(new Object[] { strValue }); + return (Serializable) constructor.newInstance(new Object[] { strValue }); } catch (InvocationTargetException e) { - throw new HbMapperException("Can not instantiate: " + className - + " using value " + strValue); + throw new HbMapperException("Can not instantiate: " + className + " using value " + strValue); } catch (InstantiationException e) { - throw new HbMapperException("Can not instantiate: " + className - + " using value " + strValue); + throw new HbMapperException("Can not instantiate: " + className + " using value " + strValue); } catch (IllegalAccessException e) { - throw new HbMapperException("Can not instantiate: " + className - + " using value " + strValue); + throw new HbMapperException("Can not instantiate: " + className + " using value " + strValue); } } @@ -521,8 +490,7 @@ public class EContainerUserType extends AbstractType implements } /** - * Creates a type of proxy object which keeps the container class and - * container id + * Creates a type of proxy object which keeps the container class and container id */ private class ContainerPointer implements Serializable { /** @@ -554,11 +522,10 @@ public class EContainerUserType extends AbstractType implements } public Size[] defaultSizes(Mapping mapping) throws MappingException { - return new Size[]{new Size(), new Size()}; + return new Size[] { new Size(), new Size() }; } - public Object deepCopy(Object value, SessionFactoryImplementor factory) - throws HibernateException { + public Object deepCopy(Object value, SessionFactoryImplementor factory) throws HibernateException { return value; } }
\ No newline at end of file diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/econtainer/NewEContainerFeatureIDPropertyHandler.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/econtainer/NewEContainerFeatureIDPropertyHandler.java index 6aac42c3a..d7d36eb76 100644 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/econtainer/NewEContainerFeatureIDPropertyHandler.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/econtainer/NewEContainerFeatureIDPropertyHandler.java @@ -51,15 +51,14 @@ import org.hibernate.property.Setter; * @version $Revision: 1.4 $ */ -public class NewEContainerFeatureIDPropertyHandler implements PropertyAccessor, - Getter, Setter, ExtensionPoint { +public class NewEContainerFeatureIDPropertyHandler implements PropertyAccessor, Getter, Setter, + ExtensionPoint { /** * Generated Serial Version UID */ private static final long serialVersionUID = -414024662032391298L; - private static Log log = LogFactory - .getLog(NewEContainerFeatureIDPropertyHandler.class); + private static Log log = LogFactory.getLog(NewEContainerFeatureIDPropertyHandler.class); private Field ecField; @@ -71,8 +70,7 @@ public class NewEContainerFeatureIDPropertyHandler implements PropertyAccessor, } @SuppressWarnings("rawtypes") - public Getter getGetter(Class theClass, String propertyName) - throws PropertyNotFoundException { + public Getter getGetter(Class theClass, String propertyName) throws PropertyNotFoundException { return this; } @@ -86,8 +84,7 @@ public class NewEContainerFeatureIDPropertyHandler implements PropertyAccessor, } @SuppressWarnings("rawtypes") - public Setter getSetter(Class theClass, String propertyName) - throws PropertyNotFoundException { + public Setter getSetter(Class theClass, String propertyName) throws PropertyNotFoundException { return this; } @@ -103,13 +100,13 @@ public class NewEContainerFeatureIDPropertyHandler implements PropertyAccessor, } @SuppressWarnings("rawtypes") - public Object getForInsert(Object owner, Map mergeMap, - SessionImplementor session) throws HibernateException { + public Object getForInsert(Object owner, Map mergeMap, SessionImplementor session) + throws HibernateException { return get(owner); } - public void set(Object target, Object value, - SessionFactoryImplementor factory) throws HibernateException { + public void set(Object target, Object value, SessionFactoryImplementor factory) + throws HibernateException { AssertUtil.assertInstanceOfNotNull(target, InternalEObject.class); AssertUtil.assertInstanceOf(value, EContainerFeatureIDHolder.class); @@ -120,30 +117,24 @@ public class NewEContainerFeatureIDPropertyHandler implements PropertyAccessor, FieldUtil.callMethod( target, "eBasicSetContainerFeatureID", - new Object[] { getContainerFeatureId( - holder.getEClass(), (EObject) target, + new Object[] { getContainerFeatureId(holder.getEClass(), (EObject) target, holder.getEFeature()) }); } else { try { - ecField.set( - target, - getContainerFeatureId(holder.getEClass(), - (EObject) target, holder.getEFeature())); + ecField.set(target, + getContainerFeatureId(holder.getEClass(), (EObject) target, holder.getEFeature())); } catch (Exception e) { - throw new HbMapperException( - "Exception when setting econtainer for: " - + target.getClass().getName() - + " to value: " + value, e); + throw new HbMapperException("Exception when setting econtainer for: " + + target.getClass().getName() + " to value: " + value, e); } } } } - public int getContainerFeatureId(EClass containingEClass, - EObject contained, EStructuralFeature eFeature) { + public int getContainerFeatureId(EClass containingEClass, EObject contained, + EStructuralFeature eFeature) { if (eFeature instanceof EAttribute) { - return InternalEObject.EOPPOSITE_FEATURE_BASE - - containingEClass.getFeatureID(eFeature); + return InternalEObject.EOPPOSITE_FEATURE_BASE - containingEClass.getFeatureID(eFeature); } final EReference eReference = (EReference) eFeature; @@ -151,8 +142,7 @@ public class NewEContainerFeatureIDPropertyHandler implements PropertyAccessor, final EReference containerEReference = eReference.getEOpposite(); return contained.eClass().getFeatureID(containerEReference); } else { - return InternalEObject.EOPPOSITE_FEATURE_BASE - - containingEClass.getFeatureID(eReference); + return InternalEObject.EOPPOSITE_FEATURE_BASE - containingEClass.getFeatureID(eReference); } } diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/elist/FeatureMapEntryComponentTuplizer.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/elist/FeatureMapEntryComponentTuplizer.java index 59f3c6b13..f525ad06f 100644 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/elist/FeatureMapEntryComponentTuplizer.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/elist/FeatureMapEntryComponentTuplizer.java @@ -38,7 +38,8 @@ import org.hibernate.tuple.Instantiator; import org.hibernate.tuple.component.AbstractComponentTuplizer; /** - * Tuplizer for feature map entries. These types are mapped using the dynamic capabilities of Hibernate. + * Tuplizer for feature map entries. These types are mapped using the dynamic capabilities of + * Hibernate. * * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> * @version $Revision: 1.3 $ @@ -58,11 +59,13 @@ public class FeatureMapEntryComponentTuplizer extends AbstractComponentTuplizer } protected Getter buildGetter(Component component, Property prop) { - return getPropertyAccessor(prop, component).getGetter(component.getComponentClass(), prop.getName()); + return getPropertyAccessor(prop, component).getGetter(component.getComponentClass(), + prop.getName()); } protected Setter buildSetter(Component component, Property prop) { - return getPropertyAccessor(prop, component).getSetter(component.getComponentClass(), prop.getName()); + return getPropertyAccessor(prop, component).getSetter(component.getComponentClass(), + prop.getName()); } protected PropertyAccessor getPropertyAccessor(Property mappedProperty, Component component) { @@ -73,7 +76,8 @@ public class FeatureMapEntryComponentTuplizer extends AbstractComponentTuplizer return hds.getHbContext().createFeatureMapEntryFeatureURIAccessor(); } else if (mappedProperty.getName().compareToIgnoreCase(HbMapperConstants.PROPERTY_MIXED_CDATA) == 0) { return hds.getHbContext().createFeatureMapEntryAccessor(Constants.CDATA); - } else if (mappedProperty.getName().compareToIgnoreCase(HbMapperConstants.PROPERTY_MIXED_COMMENT) == 0) { + } else if (mappedProperty.getName().compareToIgnoreCase( + HbMapperConstants.PROPERTY_MIXED_COMMENT) == 0) { return hds.getHbContext().createFeatureMapEntryAccessor(Constants.COMMENT); } else if (mappedProperty.getName().compareToIgnoreCase(HbMapperConstants.PROPERTY_MIXED_TEXT) == 0) { return hds.getHbContext().createFeatureMapEntryAccessor(Constants.TEXT); @@ -86,15 +90,16 @@ public class FeatureMapEntryComponentTuplizer extends AbstractComponentTuplizer final MetaAttribute ma = component.getMetaAttribute(HbMapperConstants.FEATUREMAP_META); final String eclassUri = ma.getValue(); final EClass eClass = hds.getEntityNameStrategy().toEClass(eclassUri); - final EStructuralFeature efeature = StoreUtil.getEStructuralFeature(eClass, mappedProperty.getName()); + final EStructuralFeature efeature = StoreUtil.getEStructuralFeature(eClass, + mappedProperty.getName()); if (efeature == null) { throw new HbMapperException("Feature not found for property " + mappedProperty.getName()); } if (log.isDebugEnabled()) { - log.debug("Creating property accessor for " + mappedProperty.getName() + "/" + eclassUri + "/" - + efeature.getName()); + log.debug("Creating property accessor for " + mappedProperty.getName() + "/" + eclassUri + + "/" + efeature.getName()); } return hds.getHbContext().createFeatureMapEntryAccessor(efeature); diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/elist/FeatureMapEntryInstantiator.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/elist/FeatureMapEntryInstantiator.java index 9fcf99f5a..18848c5e7 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/elist/FeatureMapEntryInstantiator.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/elist/FeatureMapEntryInstantiator.java @@ -40,8 +40,7 @@ public class FeatureMapEntryInstantiator implements Instantiator { private static final long serialVersionUID = -1219767393020090471L; /** The logger */ - private static Log log = LogFactory - .getLog(FeatureMapEntryInstantiator.class); + private static Log log = LogFactory.getLog(FeatureMapEntryInstantiator.class); /** The persistentclass for which we do all this */ private final PersistentClass persistentClass; @@ -51,8 +50,7 @@ public class FeatureMapEntryInstantiator implements Instantiator { /** Constructor */ public FeatureMapEntryInstantiator(PersistentClass pc) { - AssertUtil.assertTrue(pc.getEntityName() - + " does not have a meta attribute", + AssertUtil.assertTrue(pc.getEntityName() + " does not have a meta attribute", pc.getMetaAttribute(HbMapperConstants.FEATUREMAP_META) != null); if (log.isDebugEnabled()) { log.debug("Creating fme instantiator for " + pc.getEntityName()); diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/elist/FeatureMapEntryTuplizer.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/elist/FeatureMapEntryTuplizer.java index 39ffca94e..268df8653 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/elist/FeatureMapEntryTuplizer.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/elist/FeatureMapEntryTuplizer.java @@ -38,7 +38,8 @@ import org.hibernate.tuple.Instantiator; import org.hibernate.tuple.entity.EntityMetamodel; /** - * Tuplizer for feature map entries. These types are mapped using the dynamic capabilities of Hibernate. + * Tuplizer for feature map entries. These types are mapped using the dynamic capabilities of + * Hibernate. * * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> * @version $Revision: 1.15 $ @@ -90,7 +91,8 @@ public class FeatureMapEntryTuplizer extends EMFTuplizer { return hds.getHbContext().createFeatureMapEntryFeatureURIAccessor(); } else if (mappedProperty.getName().compareToIgnoreCase(HbMapperConstants.PROPERTY_MIXED_CDATA) == 0) { return hds.getHbContext().createFeatureMapEntryAccessor(Constants.CDATA); - } else if (mappedProperty.getName().compareToIgnoreCase(HbMapperConstants.PROPERTY_MIXED_COMMENT) == 0) { + } else if (mappedProperty.getName().compareToIgnoreCase( + HbMapperConstants.PROPERTY_MIXED_COMMENT) == 0) { return hds.getHbContext().createFeatureMapEntryAccessor(Constants.COMMENT); } else if (mappedProperty.getName().compareToIgnoreCase(HbMapperConstants.PROPERTY_MIXED_TEXT) == 0) { return hds.getHbContext().createFeatureMapEntryAccessor(Constants.TEXT); @@ -102,16 +104,17 @@ public class FeatureMapEntryTuplizer extends EMFTuplizer { final String eclassUri = HbUtil.getEClassNameFromFeatureMapMeta(pc); final EClass eClass = hds.getEntityNameStrategy().toEClass(eclassUri); - final EStructuralFeature efeature = StoreUtil.getEStructuralFeature(eClass, mappedProperty.getName()); + final EStructuralFeature efeature = StoreUtil.getEStructuralFeature(eClass, + mappedProperty.getName()); if (efeature == null) { - throw new HbMapperException("Feature not found for entity/property " + pc.getEntityName() + "/" - + mappedProperty.getName()); + throw new HbMapperException("Feature not found for entity/property " + pc.getEntityName() + + "/" + mappedProperty.getName()); } if (log.isDebugEnabled()) { - log.debug("Creating property accessor for " + mappedProperty.getName() + "/" + pc.getEntityName() + "/" - + eclassUri + "/" + efeature.getName()); + log.debug("Creating property accessor for " + mappedProperty.getName() + "/" + + pc.getEntityName() + "/" + eclassUri + "/" + efeature.getName()); } return hds.getHbContext().createFeatureMapEntryAccessor(efeature); diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/elist/HbExtraLazyPersistableEList.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/elist/HbExtraLazyPersistableEList.java index 925316722..0727d6dd9 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/elist/HbExtraLazyPersistableEList.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/elist/HbExtraLazyPersistableEList.java @@ -41,16 +41,16 @@ import org.hibernate.collection.internal.PersistentList; import org.hibernate.collection.spi.PersistentCollection; /** - * Implements the hibernate persistable elist with extra lazy behavior, most - * operations should not load the complete list. This is targeted at very large - * lists. Note that this list can not work in a detached mode. + * Implements the hibernate persistable elist with extra lazy behavior, most operations should not + * load the complete list. This is targeted at very large lists. Note that this list can not work in + * a detached mode. * * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> * @version $Revision: 1.18 $ */ -public class HbExtraLazyPersistableEList<E> extends - HibernatePersistableEList<E> implements ExtensionPoint { +public class HbExtraLazyPersistableEList<E> extends HibernatePersistableEList<E> implements + ExtensionPoint { /** The logger */ // private static Log log = @@ -63,8 +63,7 @@ public class HbExtraLazyPersistableEList<E> extends private boolean previousDeliverSetting = false; /** Constructor */ - public HbExtraLazyPersistableEList(InternalEObject owner, - EStructuralFeature feature, List<E> list) { + public HbExtraLazyPersistableEList(InternalEObject owner, EStructuralFeature feature, List<E> list) { super(owner, feature, list); } @@ -76,7 +75,7 @@ public class HbExtraLazyPersistableEList<E> extends public boolean isUnique() { return false; } - + // done in superclass: // - delegateSize and delegateIsEmpty: super implementation is already extra // lazy @@ -91,8 +90,7 @@ public class HbExtraLazyPersistableEList<E> extends /* * (non-Javadoc) * - * @see org.eclipse.emf.common.util.DelegatingEList#delegateAdd(int, - * java.lang.Object) + * @see org.eclipse.emf.common.util.DelegatingEList#delegateAdd(int, java.lang.Object) */ @Override protected void delegateAdd(int index, E object) { @@ -110,28 +108,23 @@ public class HbExtraLazyPersistableEList<E> extends for (Object element : delegateList().subList(index, size())) { // for the new one set the owner if (newIndex == index) { - StoreUtil.setSyntheticListOwner(getEStructuralFeature(), - element, getOwner()); + StoreUtil.setSyntheticListOwner(getEStructuralFeature(), element, getOwner()); } - StoreUtil.setSyntheticListIndex(getEStructuralFeature(), element, - newIndex++); + StoreUtil.setSyntheticListIndex(getEStructuralFeature(), element, newIndex++); } } /* * (non-Javadoc) * - * @see - * org.eclipse.emf.common.util.DelegatingEList#delegateAdd(java.lang.Object) + * @see org.eclipse.emf.common.util.DelegatingEList#delegateAdd(java.lang.Object) */ @Override protected void delegateAdd(E object) { int newIndex = delegateList().size(); delegateList().add(object); - StoreUtil.setSyntheticListIndex(getEStructuralFeature(), object, - newIndex); - StoreUtil.setSyntheticListOwner(getEStructuralFeature(), object, - getOwner()); + StoreUtil.setSyntheticListIndex(getEStructuralFeature(), object, newIndex); + StoreUtil.setSyntheticListOwner(getEStructuralFeature(), object, getOwner()); } /* @@ -151,19 +144,17 @@ public class HbExtraLazyPersistableEList<E> extends public Iterator<E> delegateIterator() { return iterator(); } - + @Override public Iterator<E> iterator() { // return a paging iterator return LazyCollectionUtils.getPagedLoadingIterator(this, LazyCollectionUtils.DEFAULT_PAGE_SIZE); } - + /* * (non-Javadoc) * - * @see - * org.eclipse.emf.common.util.DelegatingEList#delegateContains(java.lang - * .Object) + * @see org.eclipse.emf.common.util.DelegatingEList#delegateContains(java.lang .Object) */ @Override protected boolean delegateContains(Object object) { @@ -173,9 +164,7 @@ public class HbExtraLazyPersistableEList<E> extends /* * (non-Javadoc) * - * @see - * org.eclipse.emf.common.util.DelegatingEList#delegateContainsAll(java. - * util.Collection) + * @see org.eclipse.emf.common.util.DelegatingEList#delegateContainsAll(java. util.Collection) */ @Override protected boolean delegateContainsAll(Collection<?> collection) { @@ -224,8 +213,7 @@ public class HbExtraLazyPersistableEList<E> extends // remove the removed object // if the list is not initialized then cascade deletes won't // work - final Session session = (Session) ((PersistentList) getDelegate()) - .getSession(); + final Session session = (Session) ((PersistentList) getDelegate()).getSession(); session.delete(result); } return result; @@ -239,8 +227,7 @@ public class HbExtraLazyPersistableEList<E> extends int newIndex = index; for (Object element : delegateList().subList(index, size())) { - StoreUtil.setSyntheticListIndex(getEStructuralFeature(), element, - newIndex++); + StoreUtil.setSyntheticListIndex(getEStructuralFeature(), element, newIndex++); } return result; @@ -249,8 +236,7 @@ public class HbExtraLazyPersistableEList<E> extends /* * (non-Javadoc) * - * @see org.eclipse.emf.common.util.DelegatingEList#delegateSet(int, - * java.lang.Object) + * @see org.eclipse.emf.common.util.DelegatingEList#delegateSet(int, java.lang.Object) */ @Override protected E delegateSet(int index, E object) { @@ -258,33 +244,28 @@ public class HbExtraLazyPersistableEList<E> extends // clear old object if (oldObject != null) { - StoreUtil - .resetSyntheticListInfo(getEStructuralFeature(), oldObject); + StoreUtil.resetSyntheticListInfo(getEStructuralFeature(), oldObject); } // set new object StoreUtil.setSyntheticListIndex(getEStructuralFeature(), object, index); - StoreUtil.setSyntheticListOwner(getEStructuralFeature(), object, - getOwner()); + StoreUtil.setSyntheticListOwner(getEStructuralFeature(), object, getOwner()); return oldObject; } /** - * Implements the actions which need to be done before getting/loading an - * instance. + * Implements the actions which need to be done before getting/loading an instance. */ protected synchronized void beforeLoadInstance() { final Resource res = owner.eResource(); if (res != null && res instanceof HbResource) { - final SessionWrapper sessionWrapper = ((HbResource) res) - .getSessionWrapper(); + final SessionWrapper sessionWrapper = ((HbResource) res).getSessionWrapper(); if (res.isLoaded()) // resource is loaded reopen transaction { // if the delegate is already loaded then no transaction is // required final boolean isDelegateLoaded = delegate instanceof AbstractPersistentCollection - && ((AbstractPersistentCollection) delegate) - .wasInitialized(); + && ((AbstractPersistentCollection) delegate).wasInitialized(); if (!isDelegateLoaded && !sessionWrapper.isTransactionActive()) { sessionWrapper.setFlushModeManual(); } @@ -309,15 +290,14 @@ public class HbExtraLazyPersistableEList<E> extends // disabled for now as containers are persisted by hibernate // anyway if (isContainment() && eObject.eContainer() == null) { - EContainerRepairControl.setContainer(owner, - (InternalEObject) eObject, getEStructuralFeature()); + EContainerRepairControl.setContainer(owner, (InternalEObject) eObject, + getEStructuralFeature()); } final Resource res = owner.eResource(); if (res != null && res instanceof HbResource) { // attach the new contained objects so that they are adapted // when required - ((StoreResource) res).addToContentOrAttach( - (InternalEObject) eObject, + ((StoreResource) res).addToContentOrAttach((InternalEObject) eObject, (EReference) getEStructuralFeature()); ((StoreResource) res).setIsLoading(false); } @@ -368,8 +348,7 @@ public class HbExtraLazyPersistableEList<E> extends { } else { - throw new HbMapperException("Type " - + newDelegate.getClass().getName() + " can not be " + throw new HbMapperException("Type " + newDelegate.getClass().getName() + " can not be " + " used as a replacement for elist " + logString); } } diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/elist/HbExtraLazyPersistableEMap.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/elist/HbExtraLazyPersistableEMap.java index 5abeace13..735b9aa75 100644 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/elist/HbExtraLazyPersistableEMap.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/elist/HbExtraLazyPersistableEMap.java @@ -53,12 +53,12 @@ public class HbExtraLazyPersistableEMap<K, V> extends HibernatePersistableEMap<K public HbExtraLazyPersistableEMap(InternalEObject owner, EReference eref, List<Entry<K, V>> list) { super(owner, eref, list); } - + @Override public Iterator<java.util.Map.Entry<K, V>> iterator() { return LazyCollectionUtils.getPagedLoadingIterator(this, LazyCollectionUtils.DEFAULT_PAGE_SIZE); } - + @Override public int size() { // if we are not loaded yet, we return the size of the buffered lazy @@ -66,7 +66,7 @@ public class HbExtraLazyPersistableEMap<K, V> extends HibernatePersistableEMap<K if (!isLoaded() && isHibernateListPresent()) { try { - size = ((PersistentList)((PersistableEList<?>) delegateEList).getDelegate()).size(); + size = ((PersistentList) ((PersistableEList<?>) delegateEList).getDelegate()).size(); return size; } catch (Throwable t) { // ignore on purpose, let the call to super handle it @@ -83,20 +83,25 @@ public class HbExtraLazyPersistableEMap<K, V> extends HibernatePersistableEMap<K // do a lazy get if (key != null && !isLoaded() && isHibernateListPresent()) { final Session session = getSession(); - + session.flush(); - - // create a query - final AbstractPersistentCollection collection = (AbstractPersistentCollection)getDelegate(); - final CollectionEntry collectionEntry = ((SessionImplementor)session).getPersistenceContext().getCollectionEntry(collection); - final AbstractCollectionPersister persister = (AbstractCollectionPersister)collectionEntry.getLoadedPersister(); - final String entityName = ((EntityType)persister.getCollectionMetadata().getElementType()).getAssociatedEntityName(); - final Query qry = session.createQuery("select e from " + entityName + " as e where e.key=:key and e." + StoreUtil.getExtraLazyInversePropertyName(getEStructuralFeature()) + "=:owner"); + + // create a query + final AbstractPersistentCollection collection = (AbstractPersistentCollection) getDelegate(); + final CollectionEntry collectionEntry = ((SessionImplementor) session) + .getPersistenceContext().getCollectionEntry(collection); + final AbstractCollectionPersister persister = (AbstractCollectionPersister) collectionEntry + .getLoadedPersister(); + final String entityName = ((EntityType) persister.getCollectionMetadata().getElementType()) + .getAssociatedEntityName(); + final Query qry = session.createQuery("select e from " + entityName + + " as e where e.key=:key and e." + + StoreUtil.getExtraLazyInversePropertyName(getEStructuralFeature()) + "=:owner"); qry.setParameter("key", key); qry.setParameter("owner", getOwner()); final Object result = qry.uniqueResult(); if (result instanceof Map.Entry<?, ?>) { - final Map.Entry<K, V> entry = (Map.Entry<K, V>)result; + final Map.Entry<K, V> entry = (Map.Entry<K, V>) result; return entry.getValue(); } return null; @@ -109,26 +114,26 @@ public class HbExtraLazyPersistableEMap<K, V> extends HibernatePersistableEMap<K @Override public V put(K key, V value) { if (!isLoaded() && isHibernateListPresent()) { - final Map.Entry<K, V> entry = (Map.Entry<K, V>)get(key); + final Map.Entry<K, V> entry = (Map.Entry<K, V>) get(key); if (entry != null && entry instanceof org.eclipse.emf.common.util.BasicEMap.Entry<?, ?>) { - V result = putEntry((org.eclipse.emf.common.util.BasicEMap.Entry<K, V>)entry, value); - didModify((org.eclipse.emf.common.util.BasicEMap.Entry<K, V>)entry, result); - return result; - } else { + V result = putEntry((org.eclipse.emf.common.util.BasicEMap.Entry<K, V>) entry, value); + didModify((org.eclipse.emf.common.util.BasicEMap.Entry<K, V>) entry, result); + return result; + } else { // we get here, create a new one and add it to the persistablelist... - org.eclipse.emf.common.util.BasicEMap.Entry<K, V> newEntry = newEntry(hashOf(key), key, value); + org.eclipse.emf.common.util.BasicEMap.Entry<K, V> newEntry = newEntry(hashOf(key), key, + value); delegateEList.add(newEntry); - return null; + return null; } } return super.put(key, value); } - /** Needs to be implemented by concrete subclass */ @Override - protected EList<BasicEMap.Entry<K, V>> createDelegateEList(InternalEObject owner, EStructuralFeature feature, - List<BasicEMap.Entry<K, V>> delegateORMList) { + protected EList<BasicEMap.Entry<K, V>> createDelegateEList(InternalEObject owner, + EStructuralFeature feature, List<BasicEMap.Entry<K, V>> delegateORMList) { return new HbExtraLazyPersistableEList<Entry<K, V>>(owner, feature, delegateORMList) { private static final long serialVersionUID = 1L; @@ -160,7 +165,6 @@ public class HbExtraLazyPersistableEMap<K, V> extends HibernatePersistableEMap<K }; } - @Override public boolean remove(Object object) { // TODO Auto-generated method stub @@ -178,7 +182,7 @@ public class HbExtraLazyPersistableEMap<K, V> extends HibernatePersistableEMap<K // TODO Auto-generated method stub return super.removeKey(key); } - + private boolean isHibernateListPresent() { return getDelegate() instanceof AbstractPersistentCollection; } @@ -187,7 +191,7 @@ public class HbExtraLazyPersistableEMap<K, V> extends HibernatePersistableEMap<K final AbstractPersistentCollection persistentCollection = (AbstractPersistentCollection) getDelegate(); final SessionImplementor session = ((AbstractPersistentCollection) persistentCollection) .getSession(); - return (Session)session; + return (Session) session; } - + }
\ No newline at end of file diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/elist/HibernateFeatureMapEntry.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/elist/HibernateFeatureMapEntry.java index 73610c9bf..ab0aa99ad 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/elist/HibernateFeatureMapEntry.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/elist/HibernateFeatureMapEntry.java @@ -39,9 +39,9 @@ import org.eclipse.emf.teneo.util.StoreUtil; /** * Is used to replace the EMF feature map entry with an entry which can be handled by the or layer. * - * The special feature of this entry is that all allowed features can be set, internally it keeps a list of feature - * value pairs. Only one of these pairs is the valid one, which one is determined by the value of the eStructuralFeature - * member. + * The special feature of this entry is that all allowed features can be set, internally it keeps a + * list of feature value pairs. Only one of these pairs is the valid one, which one is determined by + * the value of the eStructuralFeature member. * * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> * @version $Revision: 1.11 $ @@ -55,7 +55,8 @@ public class HibernateFeatureMapEntry implements FeatureMap.Entry.Internal, Seri private static final long serialVersionUID = 3946138277481892125L; /** - * Gets an 'normal' FeatureMap.Entry and if it is not a FeatureMapEntry replaces it with a specific implementation. + * Gets an 'normal' FeatureMap.Entry and if it is not a FeatureMapEntry replaces it with a + * specific implementation. */ public static HibernateFeatureMapEntry replaceEntry(Object obj, FeatureMap.Internal owningMap) { // do special check, in case the featuremap entry does not need to be @@ -80,8 +81,8 @@ public class HibernateFeatureMapEntry implements FeatureMap.Entry.Internal, Seri /** * Replaces standard FeatureMap.Entry with a FeatureMapEntry for a collection */ - public static Collection<HibernateFeatureMapEntry> replaceEntryAll(Collection<FeatureMap.Entry> c, - Class<?> replaceByType, FeatureMap.Internal owningMap) { + public static Collection<HibernateFeatureMapEntry> replaceEntryAll( + Collection<FeatureMap.Entry> c, Class<?> replaceByType, FeatureMap.Internal owningMap) { final ArrayList<HibernateFeatureMapEntry> newEntries = new ArrayList<HibernateFeatureMapEntry>(); final Iterator<FeatureMap.Entry> it = c.iterator(); while (it.hasNext()) { @@ -91,7 +92,8 @@ public class HibernateFeatureMapEntry implements FeatureMap.Entry.Internal, Seri } /** Creates an entry with the correct type */ - public static FeatureMap.Entry createEntry(EStructuralFeature feature, Object value, FeatureMap.Internal owningMap) { + public static FeatureMap.Entry createEntry(EStructuralFeature feature, Object value, + FeatureMap.Internal owningMap) { HibernateFeatureMapEntry entry = new HibernateFeatureMapEntry(); entry.setFeatureValue(feature, value, owningMap); return entry; @@ -100,8 +102,8 @@ public class HibernateFeatureMapEntry implements FeatureMap.Entry.Internal, Seri /** * Method which creates a list of entries based on one feature and multiple values */ - public static Collection<FeatureMap.Entry> createEntryAll(EStructuralFeature feature, Collection<?> values, - FeatureMap.Internal owningMap) { + public static Collection<FeatureMap.Entry> createEntryAll(EStructuralFeature feature, + Collection<?> values, FeatureMap.Internal owningMap) { final ArrayList<FeatureMap.Entry> entries = new ArrayList<FeatureMap.Entry>(); final Iterator<?> it = values.iterator(); while (it.hasNext()) { @@ -117,8 +119,8 @@ public class HibernateFeatureMapEntry implements FeatureMap.Entry.Internal, Seri private String eFeaturePath; /** - * The featuremap to which we are connected. Is used to determine if entries have been added to another featuremap. - * This happens in copy actions. + * The featuremap to which we are connected. Is used to determine if entries have been added to + * another featuremap. This happens in copy actions. */ private FeatureMap.Internal owningMap; @@ -186,7 +188,7 @@ public class HibernateFeatureMapEntry implements FeatureMap.Entry.Internal, Seri /** * @param structuralFeature - * the eStructuralFeature to set + * the eStructuralFeature to set */ private void setEStructuralFeature(EStructuralFeature structuralFeature) { eStructuralFeature = structuralFeature; @@ -214,8 +216,8 @@ public class HibernateFeatureMapEntry implements FeatureMap.Entry.Internal, Seri } /** - * Add a feature value combination to the entry, only one of these values is the valid one but the other nullable - * values are stored in the db + * Add a feature value combination to the entry, only one of these values is the valid one but the + * other nullable values are stored in the db */ public void addFeatureValue(EStructuralFeature feature, Object value) { // final FeatureValue fv = getFeatureValue(feature); @@ -227,9 +229,9 @@ public class HibernateFeatureMapEntry implements FeatureMap.Entry.Internal, Seri } /** - * Sets a value in this feature map entry, if no eStructuralFeature is set then it is set in the tempValue until an - * estructural feature is set. This is done because it is not certain in which order hibernate calls the property - * handlers. + * Sets a value in this feature map entry, if no eStructuralFeature is set then it is set in the + * tempValue until an estructural feature is set. This is done because it is not certain in which + * order hibernate calls the property handlers. */ public void setValue(Object value) { if (getEStructuralFeature() != null) { @@ -246,15 +248,16 @@ public class HibernateFeatureMapEntry implements FeatureMap.Entry.Internal, Seri final EAttribute eAttribute = (EAttribute) getEStructuralFeature(); final EDataType eDataType = eAttribute.getEAttributeType(); - final Object realValue = eDataType.getEPackage().getEFactoryInstance().createFromString(eDataType, - (String) value); + final Object realValue = eDataType.getEPackage().getEFactoryInstance() + .createFromString(eDataType, (String) value); return realValue; } return value; } /** Sets the exact feature value for this entry */ - public void setFeatureValue(EStructuralFeature feature, Object value, FeatureMap.Internal owningMap) { + public void setFeatureValue(EStructuralFeature feature, Object value, + FeatureMap.Internal owningMap) { featureValues.add(createFeatureValue(feature, value)); setEStructuralFeature(feature); setFeatureMap(owningMap); @@ -287,11 +290,13 @@ public class HibernateFeatureMapEntry implements FeatureMap.Entry.Internal, Seri } /** - * Sets the container property of the value if the value is an EObject and the feature is a containment feature. + * Sets the container property of the value if the value is an EObject and the feature is a + * containment feature. */ public void setContainer(InternalEObject owner) { final Object value = getValue(); - if (value != null && value instanceof InternalEObject && eStructuralFeature instanceof EReference + if (value != null && value instanceof InternalEObject + && eStructuralFeature instanceof EReference && ((EReference) eStructuralFeature).isContainment()) { EContainerRepairControl.setContainer(owner, (InternalEObject) value, eStructuralFeature); } @@ -316,10 +321,10 @@ public class HibernateFeatureMapEntry implements FeatureMap.Entry.Internal, Seri @Override public int hashCode() { /* - * Used to create a hashcode which maps all instances of one class to the same hashcode Is required because the - * normal hashcode method (see hashcode impl in emf EntryImpl) resulted in null-pointer exceptions in hibernate - * because the content of the entry was used for determining the hashcode while the object was not initialized - * from the db + * Used to create a hashcode which maps all instances of one class to the same hashcode Is + * required because the normal hashcode method (see hashcode impl in emf EntryImpl) resulted in + * null-pointer exceptions in hibernate because the content of the entry was used for + * determining the hashcode while the object was not initialized from the db */ return this.getClass().hashCode(); } @@ -330,8 +335,7 @@ public class HibernateFeatureMapEntry implements FeatureMap.Entry.Internal, Seri String prefix = eStructuralFeature.getEContainingClass().getEPackage().getNsPrefix(); eStructuralFeature.getName(); return (prefix != null && prefix.length() != 0 ? prefix + ":" + eStructuralFeature.getName() - : eStructuralFeature.getName()) - + "=" + getValue(); + : eStructuralFeature.getName()) + "=" + getValue(); } /** @@ -346,7 +350,7 @@ public class HibernateFeatureMapEntry implements FeatureMap.Entry.Internal, Seri /** * @param entityName - * the entityName to set + * the entityName to set */ public void setEntityName(String entityName) { this.entityName = entityName; @@ -378,12 +382,14 @@ public class HibernateFeatureMapEntry implements FeatureMap.Entry.Internal, Seri } /** Does inverse action on other end */ - public final NotificationChain inverseAdd(InternalEObject owner, int featureID, NotificationChain notifications) { + public final NotificationChain inverseAdd(InternalEObject owner, int featureID, + NotificationChain notifications) { return getFeatureValue().inverseAdd(owner, getValue(), featureID, notifications); } /** Does inverse action on other end */ - public final NotificationChain inverseRemove(InternalEObject owner, int featureID, NotificationChain notifications) { + public final NotificationChain inverseRemove(InternalEObject owner, int featureID, + NotificationChain notifications) { return getFeatureValue().inverseRemove(owner, getValue(), featureID, notifications); } @@ -435,13 +441,15 @@ public class HibernateFeatureMapEntry implements FeatureMap.Entry.Internal, Seri } /** Takes care of deserializing the efeature */ - private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException { + private void readObject(java.io.ObjectInputStream in) throws IOException, + ClassNotFoundException { in.defaultReadObject(); feature = StoreUtil.stringToStructureFeature(featurePath); } /** - * Returns true if this feature value corresponds to the passed feature (taking into account substitution groups + * Returns true if this feature value corresponds to the passed feature (taking into account + * substitution groups */ private boolean matchesFeature(EStructuralFeature eFeature) { if (feature.equals(eFeature)) { @@ -454,10 +462,10 @@ public class HibernateFeatureMapEntry implements FeatureMap.Entry.Internal, Seri } // compare on the basis of the affiliates (substitutiongroup) - final EStructuralFeature aff1 = ExtendedMetaData.INSTANCE.getAffiliation(owningMap.getEObject().eClass(), - feature); - final EStructuralFeature aff2 = ExtendedMetaData.INSTANCE.getAffiliation(owningMap.getEObject().eClass(), - eFeature); + final EStructuralFeature aff1 = ExtendedMetaData.INSTANCE.getAffiliation(owningMap + .getEObject().eClass(), feature); + final EStructuralFeature aff2 = ExtendedMetaData.INSTANCE.getAffiliation(owningMap + .getEObject().eClass(), eFeature); if (aff1 != null && aff2 != null && aff1 == aff2) { return true; } @@ -486,11 +494,11 @@ public class HibernateFeatureMapEntry implements FeatureMap.Entry.Internal, Seri */ public void validate(Object value) { if (value != null && !eStructuralFeature.getEType().isInstance(value)) { - String valueClass = value instanceof EObject ? ((EObject) value).eClass().getName() : value.getClass() - .getName(); + String valueClass = value instanceof EObject ? ((EObject) value).eClass().getName() : value + .getClass().getName(); throw new ClassCastException("The feature '" + eStructuralFeature.getName() + "'s type '" - + eStructuralFeature.getEType().getName() + "' does not permit a value of type '" + valueClass - + "'"); + + eStructuralFeature.getEType().getName() + "' does not permit a value of type '" + + valueClass + "'"); } } } @@ -523,8 +531,8 @@ public class HibernateFeatureMapEntry implements FeatureMap.Entry.Internal, Seri } /** Does inverse action on other end */ - private NotificationChain inverseAdd(InternalEObject owner, InternalEObject otherEnd, int featureID, - NotificationChain notifications) { + private NotificationChain inverseAdd(InternalEObject owner, InternalEObject otherEnd, + int featureID, NotificationChain notifications) { if (otherEnd != null) { int containmentFeatureID = owner.eClass().getFeatureID(eStructuralFeature); notifications = otherEnd.eInverseAdd(owner, InternalEObject.EOPPOSITE_FEATURE_BASE @@ -535,8 +543,8 @@ public class HibernateFeatureMapEntry implements FeatureMap.Entry.Internal, Seri } /** Does inverse action on other end */ - private NotificationChain inverseRemove(InternalEObject owner, InternalEObject otherEnd, int featureID, - NotificationChain notifications) { + private NotificationChain inverseRemove(InternalEObject owner, InternalEObject otherEnd, + int featureID, NotificationChain notifications) { if (otherEnd != null) { int containmentFeatureID = owner.eClass().getFeatureID(eStructuralFeature); notifications = otherEnd.eInverseRemove(owner, InternalEObject.EOPPOSITE_FEATURE_BASE @@ -575,22 +583,24 @@ public class HibernateFeatureMapEntry implements FeatureMap.Entry.Internal, Seri } /** Does inverse action on other end */ - private final NotificationChain inverseAdd(InternalEObject owner, InternalEObject otherEnd, int featureID, - NotificationChain notifications) { + private final NotificationChain inverseAdd(InternalEObject owner, InternalEObject otherEnd, + int featureID, NotificationChain notifications) { if (otherEnd != null) { - notifications = otherEnd.eInverseAdd(owner, otherEnd.eClass().getFeatureID( - ((EReference) eStructuralFeature).getEOpposite()), null, notifications); + notifications = otherEnd.eInverseAdd(owner, + otherEnd.eClass().getFeatureID(((EReference) eStructuralFeature).getEOpposite()), null, + notifications); } return notifications; } /** Does inverse action on other end */ - private final NotificationChain inverseRemove(InternalEObject owner, InternalEObject otherEnd, int featureID, - NotificationChain notifications) { + private final NotificationChain inverseRemove(InternalEObject owner, InternalEObject otherEnd, + int featureID, NotificationChain notifications) { if (otherEnd != null) { - notifications = otherEnd.eInverseRemove(owner, otherEnd.eClass().getFeatureID( - ((EReference) eStructuralFeature).getEOpposite()), null, notifications); + notifications = otherEnd.eInverseRemove(owner, + otherEnd.eClass().getFeatureID(((EReference) eStructuralFeature).getEOpposite()), null, + notifications); } return notifications; } diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/elist/HibernatePersistableEList.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/elist/HibernatePersistableEList.java index 9470377b1..c91c580b8 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/elist/HibernatePersistableEList.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/elist/HibernatePersistableEList.java @@ -56,8 +56,8 @@ import org.hibernate.type.Type; * @version $Revision: 1.35 $ */ -public class HibernatePersistableEList<E> extends PersistableEList<E> implements - ExtensionPoint, PersistentCollection { +public class HibernatePersistableEList<E> extends PersistableEList<E> implements ExtensionPoint, + PersistentCollection { /** * Serial Version ID */ @@ -66,8 +66,7 @@ public class HibernatePersistableEList<E> extends PersistableEList<E> implements private static Log log = LogFactory.getLog(HibernatePersistableEList.class); /** Constructor */ - public HibernatePersistableEList(InternalEObject owner, - EStructuralFeature feature, List<E> list) { + public HibernatePersistableEList(InternalEObject owner, EStructuralFeature feature, List<E> list) { super(owner, feature, list); } @@ -77,8 +76,8 @@ public class HibernatePersistableEList<E> extends PersistableEList<E> implements } /** - * Override isLoaded to check if the delegate lists was not already loaded - * by hibernate behind the scenes, this happens with eagerly loaded lists. + * Override isLoaded to check if the delegate lists was not already loaded by hibernate behind the + * scenes, this happens with eagerly loaded lists. */ @Override public boolean isLoaded() { @@ -90,9 +89,7 @@ public class HibernatePersistableEList<E> extends PersistableEList<E> implements && ((AbstractPersistentCollection) delegate).wasInitialized(); if (!super.isLoaded() && !isLoading() && isDelegateLoaded) { if (log.isDebugEnabled()) { - log - .debug("Persistentlist already initialized, probably eagerly loaded: " - + getLogString()); + log.debug("Persistentlist already initialized, probably eagerly loaded: " + getLogString()); } try { setIsLoading(true); @@ -131,19 +128,14 @@ public class HibernatePersistableEList<E> extends PersistableEList<E> implements // if the delegate is already loaded then no transaction is // required final boolean isDelegateLoaded = delegate instanceof AbstractPersistentCollection - && ((AbstractPersistentCollection) delegate) - .wasInitialized(); - if (!isDelegateLoaded - && !sessionWrapper.isTransactionActive()) { - log - .debug("Reconnecting session to read a lazy collection, elist: " - + logString); + && ((AbstractPersistentCollection) delegate).wasInitialized(); + if (!isDelegateLoaded && !sessionWrapper.isTransactionActive()) { + log.debug("Reconnecting session to read a lazy collection, elist: " + logString); controlsTransaction = true; sessionWrapper.beginTransaction(); sessionWrapper.setFlushModeManual(); } else { - log - .debug("Delegate loaded or resource session is still active, using it"); + log.debug("Delegate loaded or resource session is still active, using it"); } } else if (log.isDebugEnabled()) { log.debug("Elist uses session from resource, " + logString); @@ -165,8 +157,7 @@ public class HibernatePersistableEList<E> extends PersistableEList<E> implements if (isContainment()) { for (Object element : objs) { if (element instanceof InternalEObject) { - EContainerRepairControl.setContainer(owner, - (InternalEObject) element, + EContainerRepairControl.setContainer(owner, (InternalEObject) element, getEStructuralFeature()); } } @@ -178,16 +169,14 @@ public class HibernatePersistableEList<E> extends PersistableEList<E> implements // when required for (Object element : objs) { if (element instanceof EObject) { - ((StoreResource) res).addToContentOrAttach( - (InternalEObject) element, + ((StoreResource) res).addToContentOrAttach((InternalEObject) element, (EReference) getEStructuralFeature()); } } } - + if (log.isDebugEnabled()) { - log.debug("Loaded " + objs.length + " from backend store for " - + logString); + log.debug("Loaded " + objs.length + " from backend store for " + logString); } } finally { if (controlsTransaction) { @@ -249,8 +238,7 @@ public class HibernatePersistableEList<E> extends PersistableEList<E> implements { } else { - throw new HbMapperException("Type " - + newDelegate.getClass().getName() + " can not be " + throw new HbMapperException("Type " + newDelegate.getClass().getName() + " can not be " + " used as a replacement for elist " + logString); } } @@ -267,19 +255,16 @@ public class HibernatePersistableEList<E> extends PersistableEList<E> implements return false; } - public void afterRowInsert(CollectionPersister persister, Object entry, - int i) throws HibernateException { + public void afterRowInsert(CollectionPersister persister, Object entry, int i) + throws HibernateException { if (isPersistencyWrapped()) { - ((PersistentCollection) delegate).afterRowInsert(persister, entry, - i); + ((PersistentCollection) delegate).afterRowInsert(persister, entry, i); } } - public void beforeInitialize(CollectionPersister persister, - int anticipatedSize) { + public void beforeInitialize(CollectionPersister persister, int anticipatedSize) { if (isPersistencyWrapped()) { - ((PersistentCollection) delegate).beforeInitialize(persister, - anticipatedSize); + ((PersistentCollection) delegate).beforeInitialize(persister, anticipatedSize); } } @@ -301,8 +286,7 @@ public class HibernatePersistableEList<E> extends PersistableEList<E> implements } } - public Serializable disassemble(CollectionPersister persister) - throws HibernateException { + public Serializable disassemble(CollectionPersister persister) throws HibernateException { if (isPersistencyWrapped()) { return ((PersistentCollection) delegate).disassemble(persister); } @@ -337,8 +321,7 @@ public class HibernatePersistableEList<E> extends PersistableEList<E> implements return false; } - public boolean equalsSnapshot(CollectionPersister persister) - throws HibernateException { + public boolean equalsSnapshot(CollectionPersister persister) throws HibernateException { if (isPersistencyWrapped()) { return ((PersistentCollection) delegate).equalsSnapshot(persister); } @@ -351,11 +334,10 @@ public class HibernatePersistableEList<E> extends PersistableEList<E> implements } } - public Iterator<?> getDeletes(CollectionPersister persister, - boolean indexIsFormula) throws HibernateException { + public Iterator<?> getDeletes(CollectionPersister persister, boolean indexIsFormula) + throws HibernateException { if (isPersistencyWrapped()) { - return ((PersistentCollection) delegate).getDeletes(persister, - indexIsFormula); + return ((PersistentCollection) delegate).getDeletes(persister, indexIsFormula); } return null; } @@ -376,8 +358,7 @@ public class HibernatePersistableEList<E> extends PersistableEList<E> implements public Object getIndex(Object entry, int i, CollectionPersister persister) { if (isPersistencyWrapped()) { - return ((PersistentCollection) delegate).getIndex(entry, i, - persister); + return ((PersistentCollection) delegate).getIndex(entry, i, persister); } return null; } @@ -392,8 +373,7 @@ public class HibernatePersistableEList<E> extends PersistableEList<E> implements public Collection<?> getOrphans(Serializable snapshot, String entityName) throws HibernateException { if (isPersistencyWrapped()) { - return ((PersistentCollection) delegate).getOrphans(snapshot, - entityName); + return ((PersistentCollection) delegate).getOrphans(snapshot, entityName); } return null; } @@ -407,8 +387,7 @@ public class HibernatePersistableEList<E> extends PersistableEList<E> implements public Collection<?> getQueuedOrphans(String entityName) { if (isPersistencyWrapped()) { - return ((PersistentCollection) delegate) - .getQueuedOrphans(entityName); + return ((PersistentCollection) delegate).getQueuedOrphans(entityName); } return null; } @@ -420,8 +399,7 @@ public class HibernatePersistableEList<E> extends PersistableEList<E> implements return null; } - public Serializable getSnapshot(CollectionPersister persister) - throws HibernateException { + public Serializable getSnapshot(CollectionPersister persister) throws HibernateException { if (isPersistencyWrapped()) { return ((PersistentCollection) delegate).getSnapshot(persister); } @@ -430,8 +408,7 @@ public class HibernatePersistableEList<E> extends PersistableEList<E> implements public Object getSnapshotElement(Object entry, int i) { if (isPersistencyWrapped()) { - return ((PersistentCollection) delegate).getSnapshotElement(entry, - i); + return ((PersistentCollection) delegate).getSnapshotElement(entry, i); } return null; } @@ -457,11 +434,10 @@ public class HibernatePersistableEList<E> extends PersistableEList<E> implements return false; } - public void initializeFromCache(CollectionPersister persister, - Serializable disassembled, Object owner) throws HibernateException { + public void initializeFromCache(CollectionPersister persister, Serializable disassembled, + Object owner) throws HibernateException { if (isPersistencyWrapped()) { - ((PersistentCollection) delegate).initializeFromCache(persister, - disassembled, owner); + ((PersistentCollection) delegate).initializeFromCache(persister, disassembled, owner); } } @@ -507,11 +483,9 @@ public class HibernatePersistableEList<E> extends PersistableEList<E> implements return false; } - public boolean needsInserting(Object entry, int i, Type elemType) - throws HibernateException { + public boolean needsInserting(Object entry, int i, Type elemType) throws HibernateException { if (isPersistencyWrapped()) { - return ((PersistentCollection) delegate).needsInserting(entry, i, - elemType); + return ((PersistentCollection) delegate).needsInserting(entry, i, elemType); } return false; } @@ -523,11 +497,9 @@ public class HibernatePersistableEList<E> extends PersistableEList<E> implements return false; } - public boolean needsUpdating(Object entry, int i, Type elemType) - throws HibernateException { + public boolean needsUpdating(Object entry, int i, Type elemType) throws HibernateException { if (isPersistencyWrapped()) { - return ((PersistentCollection) delegate).needsUpdating(entry, i, - elemType); + return ((PersistentCollection) delegate).needsUpdating(entry, i, elemType); } return false; } @@ -555,13 +527,11 @@ public class HibernatePersistableEList<E> extends PersistableEList<E> implements .getSession(); return isConnectedToSession(session); } - + private final boolean isConnectedToSession(SessionImplementor session) { final PersistentCollection persistentCollection = (PersistentCollection) getDelegate(); - return session != null - && session.isOpen() - && session.getPersistenceContext().containsCollection( - persistentCollection); + return session != null && session.isOpen() + && session.getPersistenceContext().containsCollection(persistentCollection); } @Override @@ -569,8 +539,7 @@ public class HibernatePersistableEList<E> extends PersistableEList<E> implements return delegateSize() == 0; } - public void preInsert(CollectionPersister persister) - throws HibernateException { + public void preInsert(CollectionPersister persister) throws HibernateException { if (isPersistencyWrapped()) { ((PersistentCollection) delegate).preInsert(persister); } @@ -583,18 +552,15 @@ public class HibernatePersistableEList<E> extends PersistableEList<E> implements return null; } - public Object readFrom(ResultSet rs, CollectionPersister role, - CollectionAliases descriptor, Object owner) - throws HibernateException, SQLException { + public Object readFrom(ResultSet rs, CollectionPersister role, CollectionAliases descriptor, + Object owner) throws HibernateException, SQLException { if (isPersistencyWrapped()) { - return ((PersistentCollection) delegate).readFrom(rs, role, - descriptor, owner); + return ((PersistentCollection) delegate).readFrom(rs, role, descriptor, owner); } return null; } - public boolean setCurrentSession(SessionImplementor session) - throws HibernateException { + public boolean setCurrentSession(SessionImplementor session) throws HibernateException { if (isPersistencyWrapped()) { return ((PersistentCollection) delegate).setCurrentSession(session); } @@ -615,8 +581,7 @@ public class HibernatePersistableEList<E> extends PersistableEList<E> implements public boolean unsetSession(SessionImplementor currentSession) { if (isPersistencyWrapped()) { - return ((PersistentCollection) delegate) - .unsetSession(currentSession); + return ((PersistentCollection) delegate).unsetSession(currentSession); } return false; } diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/elist/HibernatePersistableEMap.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/elist/HibernatePersistableEMap.java index 4201c575e..bc78e928e 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/elist/HibernatePersistableEMap.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/elist/HibernatePersistableEMap.java @@ -47,8 +47,7 @@ import org.hibernate.collection.spi.PersistentCollection; * @version $Revision: 1.13 $ */ -public class HibernatePersistableEMap<K, V> extends PersistableEMap<K, V> - implements ExtensionPoint { +public class HibernatePersistableEMap<K, V> extends PersistableEMap<K, V> implements ExtensionPoint { /** * Serial Version ID */ @@ -60,8 +59,7 @@ public class HibernatePersistableEMap<K, V> extends PersistableEMap<K, V> private Long cachedSize = null; /** Constructor */ - public HibernatePersistableEMap(InternalEObject owner, EReference eref, - List<Entry<K, V>> list) { + public HibernatePersistableEMap(InternalEObject owner, EReference eref, List<Entry<K, V>> list) { super(eref.getEReferenceType(), owner, eref, list); } @@ -72,8 +70,7 @@ public class HibernatePersistableEMap<K, V> extends PersistableEMap<K, V> boolean controlsTransaction = false; boolean err = true; Resource res = null; - final List<?> delegate = ((HibernatePersistableEList<?>) delegateEList) - .getDelegate(); + final List<?> delegate = ((HibernatePersistableEList<?>) delegateEList).getDelegate(); try { res = getEObject().eResource(); if (res != null && res instanceof HbResource) { @@ -83,13 +80,10 @@ public class HibernatePersistableEMap<K, V> extends PersistableEMap<K, V> // if the delegate is already loaded then no transaction is // required final boolean isDelegateLoaded = delegate instanceof AbstractPersistentCollection - && ((AbstractPersistentCollection) delegate) - .wasInitialized(); - if (!isDelegateLoaded - && !sessionWrapper.isTransactionActive()) { + && ((AbstractPersistentCollection) delegate).wasInitialized(); + if (!isDelegateLoaded && !sessionWrapper.isTransactionActive()) { if (log.isDebugEnabled()) { - log.debug("Reconnecting session to read a lazy collection, elist: " - + logString); + log.debug("Reconnecting session to read a lazy collection, elist: " + logString); } controlsTransaction = true; sessionWrapper.beginTransaction(); @@ -118,15 +112,13 @@ public class HibernatePersistableEMap<K, V> extends PersistableEMap<K, V> // when required for (Object element : objs) { if (element instanceof EObject) { - ((StoreResource) res).addToContentOrAttach( - (InternalEObject) element, + ((StoreResource) res).addToContentOrAttach((InternalEObject) element, (EReference) getEStructuralFeature()); } } } if (log.isDebugEnabled()) { - log.debug("Loaded " + objs.length + " from backend store for " - + logString); + log.debug("Loaded " + objs.length + " from backend store for " + logString); } } finally { if (controlsTransaction) { @@ -158,8 +150,8 @@ public class HibernatePersistableEMap<K, V> extends PersistableEMap<K, V> } /** - * Overridden because of access to size attribute. This version will try to - * read the collection size without lading it if it is lazy loaded + * Overridden because of access to size attribute. This version will try to read the collection + * size without lading it if it is lazy loaded */ @Override public int size() { @@ -173,11 +165,9 @@ public class HibernatePersistableEMap<K, V> extends PersistableEMap<K, V> .getDelegate(); if (abstractPersistentCollection.wasInitialized()) { if (abstractPersistentCollection instanceof PersistentList) { - return ((PersistentList) abstractPersistentCollection) - .size(); + return ((PersistentList) abstractPersistentCollection).size(); } else if (abstractPersistentCollection instanceof PersistentMap) { - return ((PersistentMap) abstractPersistentCollection) - .size(); + return ((PersistentMap) abstractPersistentCollection).size(); } } else if (cachedSize != null) { return cachedSize.intValue(); @@ -190,10 +180,8 @@ public class HibernatePersistableEMap<K, V> extends PersistableEMap<K, V> // the list without loading it s.flush(); cachedSize = ((Long) s - .createFilter( - ((PersistableEList<?>) delegateEList) - .getDelegate(), - "select count(*)").list().get(0)); + .createFilter(((PersistableEList<?>) delegateEList).getDelegate(), "select count(*)") + .list().get(0)); size = cachedSize.intValue(); return cachedSize.intValue(); } catch (Throwable t) { @@ -207,11 +195,9 @@ public class HibernatePersistableEMap<K, V> extends PersistableEMap<K, V> /** Needs to be implemented by concrete subclass */ @Override - protected EList<BasicEMap.Entry<K, V>> createDelegateEList( - InternalEObject owner, EStructuralFeature feature, - List<BasicEMap.Entry<K, V>> delegateORMList) { - return new HibernatePersistableEList<Entry<K, V>>(owner, feature, - delegateORMList) { + protected EList<BasicEMap.Entry<K, V>> createDelegateEList(InternalEObject owner, + EStructuralFeature feature, List<BasicEMap.Entry<K, V>> delegateORMList) { + return new HibernatePersistableEList<Entry<K, V>>(owner, feature, delegateORMList) { private static final long serialVersionUID = 1L; @Override @@ -220,8 +206,7 @@ public class HibernatePersistableEMap<K, V> extends PersistableEMap<K, V> } @Override - protected void didSet(int index, Entry<K, V> newObject, - Entry<K, V> oldObject) { + protected void didSet(int index, Entry<K, V> newObject, Entry<K, V> oldObject) { didRemove(index, oldObject); didAdd(index, newObject); } @@ -237,8 +222,7 @@ public class HibernatePersistableEMap<K, V> extends PersistableEMap<K, V> } @Override - protected void didMove(int index, Entry<K, V> movedObject, - int oldIndex) { + protected void didMove(int index, Entry<K, V> movedObject, int oldIndex) { HibernatePersistableEMap.this.doMove(movedObject); } }; diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/elist/HibernatePersistableFeatureMap.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/elist/HibernatePersistableFeatureMap.java index cf3d2bdfb..501065452 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/elist/HibernatePersistableFeatureMap.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/elist/HibernatePersistableFeatureMap.java @@ -56,7 +56,8 @@ public class HibernatePersistableFeatureMap extends PersistableFeatureMap implem private static Log log = LogFactory.getLog(HibernatePersistableFeatureMap.class); /** Constructor */ - public HibernatePersistableFeatureMap(InternalEObject owner, EStructuralFeature feature, List<FeatureMap.Entry> list) { + public HibernatePersistableFeatureMap(InternalEObject owner, EStructuralFeature feature, + List<FeatureMap.Entry> list) { super(owner, feature, list); if (isLoaded()) { @@ -85,7 +86,8 @@ public class HibernatePersistableFeatureMap extends PersistableFeatureMap implem /** Shortcut to replace entries */ protected FeatureMap.Entry replaceEntry(Object entry) { - if (entry instanceof HibernateFeatureMapEntry && ((HibernateFeatureMapEntry) entry).belongsToFeatureMap(this)) { + if (entry instanceof HibernateFeatureMapEntry + && ((HibernateFeatureMapEntry) entry).belongsToFeatureMap(this)) { return (HibernateFeatureMapEntry) entry; } @@ -101,8 +103,8 @@ public class HibernatePersistableFeatureMap extends PersistableFeatureMap implem } /** - * Override isLoaded to check if the delegate lists was not already loaded by hibernate behind the scenes, this - * happens with eagerly loaded lists. + * Override isLoaded to check if the delegate lists was not already loaded by hibernate behind the + * scenes, this happens with eagerly loaded lists. */ @Override public boolean isLoaded() { @@ -114,7 +116,8 @@ public class HibernatePersistableFeatureMap extends PersistableFeatureMap implem return false; } if (log.isDebugEnabled()) { - log.debug("Persistentlist already initialized, probably eagerly loaded: " + getLogString()); + log.debug("Persistentlist already initialized, probably eagerly loaded: " + + getLogString()); } try { setIsLoading(true); @@ -209,12 +212,12 @@ public class HibernatePersistableFeatureMap extends PersistableFeatureMap implem @Override public void replaceDelegate(List<FeatureMap.Entry> newDelegate) { if (newDelegate instanceof PersistentList) { - AssertUtil.assertTrue("This elist " + logString + " contains a different list than the " + " passed list", - ((PersistentList) newDelegate).isWrapper(delegate)); + AssertUtil.assertTrue("This elist " + logString + " contains a different list than the " + + " passed list", ((PersistentList) newDelegate).isWrapper(delegate)); super.replaceDelegate(newDelegate); } else if (newDelegate instanceof PersistentBag) { - AssertUtil.assertTrue("This elist " + logString + " contains a different list than the " + " passed list", - ((PersistentBag) newDelegate).isWrapper(delegate)); + AssertUtil.assertTrue("This elist " + logString + " contains a different list than the " + + " passed list", ((PersistentBag) newDelegate).isWrapper(delegate)); super.replaceDelegate(newDelegate); } else { throw new HbMapperException("Type " + newDelegate.getClass().getName() + " can not be " @@ -232,7 +235,8 @@ public class HibernatePersistableFeatureMap extends PersistableFeatureMap implem protected Entry delegateRemove(int index) { final Entry old = super.delegateRemove(index); - if (old.getEStructuralFeature() instanceof EReference && getDelegate() instanceof PersistentList) { + if (old.getEStructuralFeature() instanceof EReference + && getDelegate() instanceof PersistentList) { final PersistentList pl = (PersistentList) getDelegate(); final EReference eref = (EReference) old.getEStructuralFeature(); if (eref.isContainment()) { diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/elist/MapHibernatePersistableEMap.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/elist/MapHibernatePersistableEMap.java index a293e30fd..b6d785e33 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/elist/MapHibernatePersistableEMap.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/elist/MapHibernatePersistableEMap.java @@ -45,7 +45,8 @@ import org.hibernate.collection.internal.PersistentMap; * @version $Revision: 1.9 $ */ -public class MapHibernatePersistableEMap<K, V> extends MapPersistableEMap<K, V> implements ExtensionPoint { +public class MapHibernatePersistableEMap<K, V> extends MapPersistableEMap<K, V> implements + ExtensionPoint { /** * Serial Version ID */ @@ -55,7 +56,7 @@ public class MapHibernatePersistableEMap<K, V> extends MapPersistableEMap<K, V> private static Log log = LogFactory.getLog(MapHibernatePersistableEMap.class); private Long cachedSize = null; - + /** * Constructor: this version will take a natural map as input (probided by hibernate) and * transform the entries into the EMF keyToValue format @@ -67,11 +68,12 @@ public class MapHibernatePersistableEMap<K, V> extends MapPersistableEMap<K, V> } /** - * This constructor is usually called when the list is created and filled by the user first. - * when called by a hibernate load, the other overload with a map input is used instead. + * This constructor is usually called when the list is created and filled by the user first. when + * called by a hibernate load, the other overload with a map input is used instead. * */ - public MapHibernatePersistableEMap(InternalEObject owner, EReference eref, List<BasicEMap.Entry<K, V>> list) { + public MapHibernatePersistableEMap(InternalEObject owner, EReference eref, + List<BasicEMap.Entry<K, V>> list) { super(eref.getEReferenceType(), owner, eref, list); } @@ -81,8 +83,8 @@ public class MapHibernatePersistableEMap<K, V> extends MapPersistableEMap<K, V> } /** - * Override isLoaded to check if the delegate lists was not already loaded by hibernate behind - * the scenes, this happens with eagerly loaded lists. + * Override isLoaded to check if the delegate lists was not already loaded by hibernate behind the + * scenes, this happens with eagerly loaded lists. */ @Override public boolean isLoaded() { @@ -124,7 +126,8 @@ public class MapHibernatePersistableEMap<K, V> extends MapPersistableEMap<K, V> // if we are not loaded yet, we return the size of the buffered lazy // load delegate if (!isMapValueIsEAttribute() && this.getORMMapDelegate() != null) { - if (!this.isORMMapDelegateLoaded() && (this.getORMMapDelegate() instanceof AbstractPersistentCollection)) { + if (!this.isORMMapDelegateLoaded() + && (this.getORMMapDelegate() instanceof AbstractPersistentCollection)) { if (cachedSize != null) { return cachedSize.intValue(); } @@ -137,8 +140,8 @@ public class MapHibernatePersistableEMap<K, V> extends MapPersistableEMap<K, V> // now that we have the session, we can query the size of // the list without loading it - cachedSize = - ((Long) s.createFilter(this.getORMMapDelegate(), "select count(*)").list().get(0)); + cachedSize = ((Long) s.createFilter(this.getORMMapDelegate(), "select count(*)").list() + .get(0)); size = cachedSize.intValue(); return size; } catch (Throwable t) { @@ -163,14 +166,15 @@ public class MapHibernatePersistableEMap<K, V> extends MapPersistableEMap<K, V> return false; } - return ((this.ormMapDelegate instanceof PersistentMap) && (((PersistentMap) ormMapDelegate).wasInitialized())); + return ((this.ormMapDelegate instanceof PersistentMap) && (((PersistentMap) ormMapDelegate) + .wasInitialized())); } /** * Do the actual load and wrapping. can be overridden */ @Override - @SuppressWarnings({"rawtypes","unchecked"}) + @SuppressWarnings({ "rawtypes", "unchecked" }) protected void doLoad() { SessionWrapper sessionWrapper = null; boolean controlsTransaction = false; @@ -186,9 +190,8 @@ public class MapHibernatePersistableEMap<K, V> extends MapPersistableEMap<K, V> { // if the delegate is already loaded then no transaction is // required - final boolean isDelegateLoaded = - delegate instanceof AbstractPersistentCollection && - ((AbstractPersistentCollection) delegate).wasInitialized(); + final boolean isDelegateLoaded = delegate instanceof AbstractPersistentCollection + && ((AbstractPersistentCollection) delegate).wasInitialized(); if (!isDelegateLoaded && !sessionWrapper.isTransactionActive()) { if (log.isDebugEnabled()) { log.debug("Reconnecting session to read a lazy collection, elist: " + logString); @@ -226,7 +229,7 @@ public class MapHibernatePersistableEMap<K, V> extends MapPersistableEMap<K, V> for (Object o : entrySet()) { if (o instanceof EObject) { ((StoreResource) res).addToContentOrAttach((InternalEObject) o, - (EReference) getEStructuralFeature()); + (EReference) getEStructuralFeature()); } } } diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/identifier/IdentifierCacheHandler.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/identifier/IdentifierCacheHandler.java index 1ba3f0b7d..e868e2434 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/identifier/IdentifierCacheHandler.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/identifier/IdentifierCacheHandler.java @@ -17,8 +17,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** - * Implements two maps for caching identifier and version information. - * Internally uses weakreferences and periodic purge actions to clean the maps. + * Implements two maps for caching identifier and version information. Internally uses + * weakreferences and periodic purge actions to clean the maps. * * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> * @version $Revision: 1.21 $ @@ -73,8 +73,7 @@ public class IdentifierCacheHandler { final Object id = idMap.get(new Key(obj)); if (id == null) { if (log.isDebugEnabled()) { - log.debug("ID for object " + obj.getClass().getName() - + " not found in id cache"); + log.debug("ID for object " + obj.getClass().getName() + " not found in id cache"); } return null; } @@ -87,8 +86,7 @@ public class IdentifierCacheHandler { /** Set an identifier in the cache */ public void setID(Object obj, Object id) { if (log.isDebugEnabled()) { - log.debug("Setting id: " + id + " for object " - + obj.getClass().getName() + " in idcache "); + log.debug("Setting id: " + id + " for object " + obj.getClass().getName() + " in idcache "); } if (id == null) { // actually a remove of the id @@ -145,8 +143,8 @@ public class IdentifierCacheHandler { /** Sets a version in the cache */ public void setVersion(Object obj, Object version) { if (log.isDebugEnabled()) { - log.debug("Setting version: " + version + " for object " - + obj.getClass().getName() + " in idcache "); + log.debug("Setting version: " + version + " for object " + obj.getClass().getName() + + " in idcache "); } if (version == null) { versionMap.remove(new Key(obj)); @@ -197,8 +195,8 @@ public class IdentifierCacheHandler { } /** - * Own implementation of the key in the hashmap to override the equals - * method. Equality for this cache is real memory location equality + * Own implementation of the key in the hashmap to override the equals method. Equality for this + * cache is real memory location equality */ protected static class Key { diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/identifier/IdentifierPropertyHandler.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/identifier/IdentifierPropertyHandler.java index e5e4ed104..c4d469c09 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/identifier/IdentifierPropertyHandler.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/identifier/IdentifierPropertyHandler.java @@ -29,14 +29,13 @@ import org.hibernate.property.PropertyAccessor; import org.hibernate.property.Setter; /** - * Handles getting and setting of id's in the identifiercache handler, is only - * used for synthetic id's. + * Handles getting and setting of id's in the identifiercache handler, is only used for synthetic + * id's. * * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> * @version $Revision: 1.7 $ */ -public class IdentifierPropertyHandler implements Getter, Setter, - PropertyAccessor { +public class IdentifierPropertyHandler implements Getter, Setter, PropertyAccessor { /** * Serial Version ID */ @@ -45,24 +44,20 @@ public class IdentifierPropertyHandler implements Getter, Setter, /* * (non-Javadoc) * - * @see org.hibernate.property.PropertyAccessor#getGetter(java.lang.Class, - * java.lang.String) + * @see org.hibernate.property.PropertyAccessor#getGetter(java.lang.Class, java.lang.String) */ @SuppressWarnings("rawtypes") - public Getter getGetter(Class theClass, String propertyName) - throws PropertyNotFoundException { + public Getter getGetter(Class theClass, String propertyName) throws PropertyNotFoundException { return this; } /* * (non-Javadoc) * - * @see org.hibernate.property.PropertyAccessor#getSetter(java.lang.Class, - * java.lang.String) + * @see org.hibernate.property.PropertyAccessor#getSetter(java.lang.Class, java.lang.String) */ @SuppressWarnings("rawtypes") - public Setter getSetter(Class theClass, String propertyName) - throws PropertyNotFoundException { + public Setter getSetter(Class theClass, String propertyName) throws PropertyNotFoundException { return this; } @@ -83,8 +78,8 @@ public class IdentifierPropertyHandler implements Getter, Setter, /* * (non-Javadoc) * - * @see org.hibernate.property.Getter#getForInsert(java.lang.Object, - * java.util.Map, org.hibernate.engine.SessionImplementor) + * @see org.hibernate.property.Getter#getForInsert(java.lang.Object, java.util.Map, + * org.hibernate.engine.SessionImplementor) */ @SuppressWarnings("rawtypes") public Object getForInsert(Object arg0, Map arg1, SessionImplementor arg2) @@ -123,11 +118,11 @@ public class IdentifierPropertyHandler implements Getter, Setter, /* * (non-Javadoc) * - * @see org.hibernate.property.Setter#set(java.lang.Object, - * java.lang.Object, org.hibernate.engine.SessionFactoryImplementor) + * @see org.hibernate.property.Setter#set(java.lang.Object, java.lang.Object, + * org.hibernate.engine.SessionFactoryImplementor) */ - public void set(Object target, Object value, - SessionFactoryImplementor factory) throws HibernateException { + public void set(Object target, Object value, SessionFactoryImplementor factory) + throws HibernateException { IdentifierCacheHandler.getInstance().setID(target, value); } }
\ No newline at end of file diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/identifier/IdentifierUtil.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/identifier/IdentifierUtil.java index 2a3559ef3..0c9e6abae 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/identifier/IdentifierUtil.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/identifier/IdentifierUtil.java @@ -35,9 +35,9 @@ import org.hibernate.type.AbstractStandardBasicType; import org.hibernate.type.Type; /** - * Different identifier related utilities. The current Elver store - * representation does not use the EMF id concept but uses the underlying - * hibernate identifier. This allows more flexibility than the EMF identifier. + * Different identifier related utilities. The current Elver store representation does not use the + * EMF id concept but uses the underlying hibernate identifier. This allows more flexibility than + * the EMF identifier. * * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> * @version $Revision: 1.9 $ @@ -58,15 +58,14 @@ public class IdentifierUtil { /** * Returns the identifiertype on the basis of the class of the passed object */ - public static Type getIdentifierType(String className, - SessionImplementor session) { + public static Type getIdentifierType(String className, SessionImplementor session) { Type type = identifierTypeCache.get(className); if (type != null) { return type; } - final Type identifierType = ((SessionImpl) session).getFactory() - .getClassMetadata(className).getIdentifierType(); + final Type identifierType = ((SessionImpl) session).getFactory().getClassMetadata(className) + .getIdentifierType(); identifierTypeCache.put(className, identifierType); return identifierType; } @@ -74,14 +73,12 @@ public class IdentifierUtil { /** Converts an id to a string representation */ public static String idToString(Object object, SessionImplementor session) { - return createIDString( - getIdentifierType(object.getClass().getName(), session), + return createIDString(getIdentifierType(object.getClass().getName(), session), getID(object, session)); } /** String to id */ - public static Serializable stringToId(String className, - SessionImplementor Session, String idStr) { + public static Serializable stringToId(String className, SessionImplementor Session, String idStr) { return extractID(getIdentifierType(className, Session), idStr); } @@ -95,25 +92,19 @@ public class IdentifierUtil { // for all other cases the classname of the type is encoded into the // field - final String className = idString.substring(0, - idString.indexOf(ENCODING_SEPARATOR)); - final String strValue = idString.substring(1 + idString - .indexOf(ENCODING_SEPARATOR)); + final String className = idString.substring(0, idString.indexOf(ENCODING_SEPARATOR)); + final String strValue = idString.substring(1 + idString.indexOf(ENCODING_SEPARATOR)); Constructor<?> constructor = constructorCache.get(className); if (constructor == null) { try { - final Class<?> clazz = ClassLoaderResolver - .classForName(className); - constructor = clazz - .getConstructor(new Class[] { String.class }); + final Class<?> clazz = ClassLoaderResolver.classForName(className); + constructor = clazz.getConstructor(new Class[] { String.class }); } catch (StoreClassLoadException e) { throw new HbMapperException("Class " + className + " not found"); } catch (NoSuchMethodException e) { - throw new HbMapperException( - "Class " - + className - + " does not have a constructor with a String parameter!"); + throw new HbMapperException("Class " + className + + " does not have a constructor with a String parameter!"); } } if (constructor == null) { @@ -122,27 +113,21 @@ public class IdentifierUtil { } try { - return (Serializable) constructor - .newInstance(new Object[] { strValue }); + return (Serializable) constructor.newInstance(new Object[] { strValue }); } catch (InvocationTargetException e) { - throw new HbMapperException("Can not instantiate: " + className - + " using value " + strValue); + throw new HbMapperException("Can not instantiate: " + className + " using value " + strValue); } catch (InstantiationException e) { - throw new HbMapperException("Can not instantiate: " + className - + " using value " + strValue); + throw new HbMapperException("Can not instantiate: " + className + " using value " + strValue); } catch (IllegalAccessException e) { - throw new HbMapperException("Can not instantiate: " + className - + " using value " + strValue); + throw new HbMapperException("Can not instantiate: " + className + " using value " + strValue); } } /** Returns the id of the passed object */ - @SuppressWarnings("deprecation") public static Serializable getID(EObject eobj, HbDataStore hd, SessionImplementor session) { - final String entityName = hd.getEntityNameStrategy().toEntityName( - eobj.eClass()); - final EntityPersister entityPersister = ((SessionFactoryImpl) hd - .getSessionFactory()).getEntityPersister(entityName); + final String entityName = hd.getEntityNameStrategy().toEntityName(eobj.eClass()); + final EntityPersister entityPersister = ((SessionFactoryImpl) hd.getSessionFactory()) + .getEntityPersister(entityName); return entityPersister.getIdentifier(eobj, session); } @@ -155,14 +140,12 @@ public class IdentifierUtil { // now with entity name final String entityName = session.bestGuessEntityName(object); - id = ForeignKeys.getEntityIdentifierIfNotUnsaved(entityName, object, - session); + id = ForeignKeys.getEntityIdentifierIfNotUnsaved(entityName, object, session); if (id != null) { return id; } // now the slow way - return (Serializable) IdentifierCacheHandler.getInstance() - .getID(object); + return (Serializable) IdentifierCacheHandler.getInstance().getID(object); } /** Creates an id string from a serializable object */ diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/internal/TeneoInternalEObject.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/internal/TeneoInternalEObject.java index 7a85ff477..d5bf01e66 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/internal/TeneoInternalEObject.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/internal/TeneoInternalEObject.java @@ -1,6 +1,5 @@ package org.eclipse.emf.teneo.hibernate.mapping.internal; - import org.eclipse.emf.ecore.InternalEObject; /** diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/property/DummyPropertyHandler.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/property/DummyPropertyHandler.java index fff2056e0..1f8ee2506 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/property/DummyPropertyHandler.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/property/DummyPropertyHandler.java @@ -43,24 +43,20 @@ public class DummyPropertyHandler implements Getter, Setter, PropertyAccessor { /* * (non-Javadoc) * - * @see org.hibernate.property.PropertyAccessor#getGetter(java.lang.Class, - * java.lang.String) + * @see org.hibernate.property.PropertyAccessor#getGetter(java.lang.Class, java.lang.String) */ @SuppressWarnings("rawtypes") - public Getter getGetter(Class theClass, String propertyName) - throws PropertyNotFoundException { + public Getter getGetter(Class theClass, String propertyName) throws PropertyNotFoundException { return this; } /* * (non-Javadoc) * - * @see org.hibernate.property.PropertyAccessor#getSetter(java.lang.Class, - * java.lang.String) + * @see org.hibernate.property.PropertyAccessor#getSetter(java.lang.Class, java.lang.String) */ @SuppressWarnings("rawtypes") - public Setter getSetter(Class theClass, String propertyName) - throws PropertyNotFoundException { + public Setter getSetter(Class theClass, String propertyName) throws PropertyNotFoundException { return this; } @@ -85,8 +81,8 @@ public class DummyPropertyHandler implements Getter, Setter, PropertyAccessor { /* * (non-Javadoc) * - * @see org.hibernate.property.Getter#getForInsert(java.lang.Object, - * java.util.Map, org.hibernate.engine.SessionImplementor) + * @see org.hibernate.property.Getter#getForInsert(java.lang.Object, java.util.Map, + * org.hibernate.engine.SessionImplementor) */ @SuppressWarnings("rawtypes") public Object getForInsert(Object arg0, Map arg1, SessionImplementor arg2) @@ -125,10 +121,10 @@ public class DummyPropertyHandler implements Getter, Setter, PropertyAccessor { /* * (non-Javadoc) * - * @see org.hibernate.property.Setter#set(java.lang.Object, - * java.lang.Object, org.hibernate.engine.SessionFactoryImplementor) + * @see org.hibernate.property.Setter#set(java.lang.Object, java.lang.Object, + * org.hibernate.engine.SessionFactoryImplementor) */ - public void set(Object target, Object value, - SessionFactoryImplementor factory) throws HibernateException { + public void set(Object target, Object value, SessionFactoryImplementor factory) + throws HibernateException { } }
\ No newline at end of file diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/property/EAttributePropertyHandler.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/property/EAttributePropertyHandler.java index 9362ba4ef..951879e93 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/property/EAttributePropertyHandler.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/property/EAttributePropertyHandler.java @@ -38,20 +38,18 @@ import org.hibernate.property.PropertyAccessor; import org.hibernate.property.Setter; /** - * Is a getter and setter for EMF eattribute which uses eGet and eSet.Handles - * many==false properties. + * Is a getter and setter for EMF eattribute which uses eGet and eSet.Handles many==false + * properties. * - * This class implements both the getter, setter and propertyaccessor - * interfaces. When the getGetter and getSetter methods are called it returns - * itself. + * This class implements both the getter, setter and propertyaccessor interfaces. When the getGetter + * and getSetter methods are called it returns itself. * * This accessor also handles arrays of primitive types. * * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> * @version $Revision: 1.20 $ */ -public class EAttributePropertyHandler implements Getter, Setter, - PropertyAccessor { +public class EAttributePropertyHandler implements Getter, Setter, PropertyAccessor { /** * Generated Serial Version ID */ @@ -79,12 +77,10 @@ public class EAttributePropertyHandler implements Getter, Setter, this.eAttribute = eAttribute; instanceClass = eAttribute.getEType().getInstanceClass(); if (eAttribute.getEType().getInstanceClassName() != null) { - isObjectClass = eAttribute.getEType().getInstanceClassName() - .contains("."); + isObjectClass = eAttribute.getEType().getInstanceClassName().contains("."); } AssertUtil.assertTrue(eAttribute.getName() - + " is a many feature which is not handled by this accessor ", - !eAttribute.isMany()); + + " is a many feature which is not handled by this accessor ", !eAttribute.isMany()); if (log.isDebugEnabled()) { log.debug("Created getter/setter for " + StoreUtil.toString(eAttribute)); } @@ -106,24 +102,20 @@ public class EAttributePropertyHandler implements Getter, Setter, /* * (non-Javadoc) * - * @see org.hibernate.property.PropertyAccessor#getGetter(java.lang.Class, - * java.lang.String) + * @see org.hibernate.property.PropertyAccessor#getGetter(java.lang.Class, java.lang.String) */ @SuppressWarnings("rawtypes") - public Getter getGetter(Class theClass, String propertyName) - throws PropertyNotFoundException { + public Getter getGetter(Class theClass, String propertyName) throws PropertyNotFoundException { return this; } /* * (non-Javadoc) * - * @see org.hibernate.property.PropertyAccessor#getSetter(java.lang.Class, - * java.lang.String) + * @see org.hibernate.property.PropertyAccessor#getSetter(java.lang.Class, java.lang.String) */ @SuppressWarnings("rawtypes") - public Setter getSetter(Class theClass, String propertyName) - throws PropertyNotFoundException { + public Setter getSetter(Class theClass, String propertyName) throws PropertyNotFoundException { return this; } @@ -145,8 +137,8 @@ public class EAttributePropertyHandler implements Getter, Setter, /* * (non-Javadoc) * - * @see org.hibernate.property.Getter#getForInsert(java.lang.Object, - * java.util.Map, org.hibernate.engine.SessionImplementor) + * @see org.hibernate.property.Getter#getForInsert(java.lang.Object, java.util.Map, + * org.hibernate.engine.SessionImplementor) */ @SuppressWarnings("rawtypes") public Object getForInsert(Object arg0, Map arg1, SessionImplementor arg2) @@ -185,11 +177,11 @@ public class EAttributePropertyHandler implements Getter, Setter, /* * (non-Javadoc) * - * @see org.hibernate.property.Setter#set(java.lang.Object, - * java.lang.Object, org.hibernate.engine.SessionFactoryImplementor) + * @see org.hibernate.property.Setter#set(java.lang.Object, java.lang.Object, + * org.hibernate.engine.SessionFactoryImplementor) */ - public void set(Object target, Object value, - SessionFactoryImplementor factory) throws HibernateException { + public void set(Object target, Object value, SessionFactoryImplementor factory) + throws HibernateException { EObject eobj = (EObject) target; if (value == null) { @@ -218,8 +210,7 @@ public class EAttributePropertyHandler implements Getter, Setter, } final Object setValue; - if (value != null && instanceClass != null - && value.getClass() != instanceClass) { + if (value != null && instanceClass != null && value.getClass() != instanceClass) { final Class<?> valClass = value.getClass(); if (valClass == Integer[].class) { setValue = convert((Integer[]) value); @@ -248,8 +239,7 @@ public class EAttributePropertyHandler implements Getter, Setter, private Object convert(Integer[] arr) { if (instanceClass != int[].class) { if (log.isDebugEnabled()) { - log.debug("Expecting " + instanceClass.getName() - + " as instance class but it is: " + log.debug("Expecting " + instanceClass.getName() + " as instance class but it is: " + arr.getClass().getName()); } return arr; @@ -265,8 +255,7 @@ public class EAttributePropertyHandler implements Getter, Setter, private Object convert(Boolean[] arr) { if (instanceClass != boolean[].class) { if (log.isDebugEnabled()) { - log.debug("Expecting " + instanceClass.getName() - + " as instance class but it is: " + log.debug("Expecting " + instanceClass.getName() + " as instance class but it is: " + arr.getClass().getName()); } return arr; @@ -282,8 +271,7 @@ public class EAttributePropertyHandler implements Getter, Setter, private Object convert(Byte[] arr) { if (instanceClass != byte[].class) { if (log.isDebugEnabled()) { - log.debug("Expecting " + instanceClass.getName() - + " as instance class but it is: " + log.debug("Expecting " + instanceClass.getName() + " as instance class but it is: " + arr.getClass().getName()); } return arr; @@ -299,8 +287,7 @@ public class EAttributePropertyHandler implements Getter, Setter, private Object convert(Double[] arr) { if (instanceClass != double[].class) { if (log.isDebugEnabled()) { - log.debug("Expecting " + instanceClass.getName() - + " as instance class but it is: " + log.debug("Expecting " + instanceClass.getName() + " as instance class but it is: " + arr.getClass().getName()); } return arr; @@ -316,8 +303,7 @@ public class EAttributePropertyHandler implements Getter, Setter, private Object convert(Float[] arr) { if (instanceClass != float[].class) { if (log.isDebugEnabled()) { - log.debug("Expecting " + instanceClass.getName() - + " as instance class but it is: " + log.debug("Expecting " + instanceClass.getName() + " as instance class but it is: " + arr.getClass().getName()); } return arr; @@ -333,8 +319,7 @@ public class EAttributePropertyHandler implements Getter, Setter, private Object convert(Long[] arr) { if (instanceClass != long[].class) { if (log.isDebugEnabled()) { - log.debug("Expecting [] as instance class but it is: " - + instanceClass.getName()); + log.debug("Expecting [] as instance class but it is: " + instanceClass.getName()); } return arr; } @@ -349,8 +334,7 @@ public class EAttributePropertyHandler implements Getter, Setter, private Object convert(Short[] arr) { if (instanceClass != short[].class) { if (log.isDebugEnabled()) { - log.debug("Expecting short[] as instance class but it is: " - + instanceClass.getName()); + log.debug("Expecting short[] as instance class but it is: " + instanceClass.getName()); } return arr; } @@ -363,13 +347,10 @@ public class EAttributePropertyHandler implements Getter, Setter, /** Capature all, do not convert */ private Object convert(Object arr) { - if (arr != null - && instanceClass != null - && (!instanceClass.isPrimitive() || !arr.getClass() - .isPrimitive())) { + if (arr != null && instanceClass != null + && (!instanceClass.isPrimitive() || !arr.getClass().isPrimitive())) { if (log.isDebugEnabled()) { - log.debug("Expecting " + instanceClass.getName() - + " as instance class but it is: " + log.debug("Expecting " + instanceClass.getName() + " as instance class but it is: " + arr.getClass().getName()); } } diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/property/EListPropertyHandler.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/property/EListPropertyHandler.java index 27433f647..3d363ab07 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/property/EListPropertyHandler.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/property/EListPropertyHandler.java @@ -53,17 +53,16 @@ import org.hibernate.property.PropertyAccessor; import org.hibernate.property.Setter; /** - * Implements the accessor for EMF EList members for Hibernate. This can be an - * EReference or an Eattribute with many=true. This class implements both the - * getter, setter and propertyaccessor interfaces. When the getGetter and - * getSetter methods are called it returns itself. + * Implements the accessor for EMF EList members for Hibernate. This can be an EReference or an + * Eattribute with many=true. This class implements both the getter, setter and propertyaccessor + * interfaces. When the getGetter and getSetter methods are called it returns itself. * * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> * @version $Revision: 1.39 $ */ @SuppressWarnings("unchecked") -public class EListPropertyHandler implements Getter, Setter, PropertyAccessor, - ExtensionPoint, ExtensionManagerAware { +public class EListPropertyHandler implements Getter, Setter, PropertyAccessor, ExtensionPoint, + ExtensionManagerAware { /** * Generated Serial Version ID */ @@ -88,15 +87,15 @@ public class EListPropertyHandler implements Getter, Setter, PropertyAccessor, private ExtensionManager extensionManager; /** Initialize this instance */ - public void initialize(EStructuralFeature eFeature, boolean extraLazy, - boolean newEMapMapping) { + public void initialize(EStructuralFeature eFeature, boolean extraLazy, boolean newEMapMapping) { this.extraLazy = extraLazy; this.eFeature = eFeature; if (log.isDebugEnabled()) { log.debug("Created getter/setter for " + StoreUtil.toString(eFeature)); } - AssertUtil.assertTrue("Many must be true but this isn't the case for " - + StoreUtil.toString(eFeature), eFeature.isMany()); + AssertUtil.assertTrue( + "Many must be true but this isn't the case for " + StoreUtil.toString(eFeature), + eFeature.isMany()); isAMap = StoreUtil.isMap(eFeature); this.newEMapMapping = newEMapMapping; } @@ -117,24 +116,20 @@ public class EListPropertyHandler implements Getter, Setter, PropertyAccessor, /* * (non-Javadoc) * - * @see org.hibernate.property.PropertyAccessor#getGetter(java.lang.Class, - * java.lang.String) + * @see org.hibernate.property.PropertyAccessor#getGetter(java.lang.Class, java.lang.String) */ @SuppressWarnings("rawtypes") - public Getter getGetter(Class theClass, String propertyName) - throws PropertyNotFoundException { + public Getter getGetter(Class theClass, String propertyName) throws PropertyNotFoundException { return this; } /* * (non-Javadoc) * - * @see org.hibernate.property.PropertyAccessor#getSetter(java.lang.Class, - * java.lang.String) + * @see org.hibernate.property.PropertyAccessor#getSetter(java.lang.Class, java.lang.String) */ @SuppressWarnings("rawtypes") - public Setter getSetter(Class theClass, String propertyName) - throws PropertyNotFoundException { + public Setter getSetter(Class theClass, String propertyName) throws PropertyNotFoundException { return this; } @@ -145,8 +140,7 @@ public class EListPropertyHandler implements Getter, Setter, PropertyAccessor, */ public Object get(Object owner) throws HibernateException { - final PersistentStoreAdapter adapter = StoreUtil - .getPersistentStoreAdapter((EObject) owner); + final PersistentStoreAdapter adapter = StoreUtil.getPersistentStoreAdapter((EObject) owner); final Object value = adapter.getStoreCollection(eFeature); if (value != null) { return value; @@ -160,8 +154,7 @@ public class EListPropertyHandler implements Getter, Setter, PropertyAccessor, // force the estore to create a list, otherwise the .get // will return a null value. if (eStore.size((InternalEObject) owner, eFeature) != -1) { - obj = eStore.get((InternalEObject) owner, eFeature, - EStore.NO_INDEX); + obj = eStore.get((InternalEObject) owner, eFeature, EStore.NO_INDEX); } } @@ -183,8 +176,7 @@ public class EListPropertyHandler implements Getter, Setter, PropertyAccessor, if (log.isDebugEnabled()) { log.debug("Dynamic elist, set using the esettings"); } - EcoreAccess.setManyEFeatureValue(eFeature, pelist, - (BasicEObjectImpl) owner); + EcoreAccess.setManyEFeatureValue(eFeature, pelist, (BasicEObjectImpl) owner); } else { // TODO: currently it is required to use the field setter // instead of the eSet method @@ -197,15 +189,12 @@ public class EListPropertyHandler implements Getter, Setter, PropertyAccessor, // interface while there // are multiple implementors. FieldUtil does caching of // fieldnames and fields. - final Field javaField = FieldUtil.getField(owner.getClass(), - getFieldName(owner)); + final Field javaField = FieldUtil.getField(owner.getClass(), getFieldName(owner)); try { javaField.set(owner, pelist); } catch (Exception e) { - throw new HbMapperException("The field " - + javaField.getName() - + " can not be set using object " - + pelist.getClass().getName() + " on target " + throw new HbMapperException("The field " + javaField.getName() + + " can not be set using object " + pelist.getClass().getName() + " on target " + owner.getClass().getName(), e); } } @@ -225,14 +214,13 @@ public class EListPropertyHandler implements Getter, Setter, PropertyAccessor, /* * (non-Javadoc) * - * @see org.hibernate.property.Getter#getForInsert(java.lang.Object, - * java.util.Map, org.hibernate.engine.SessionImplementor) + * @see org.hibernate.property.Getter#getForInsert(java.lang.Object, java.util.Map, + * org.hibernate.engine.SessionImplementor) */ @SuppressWarnings("rawtypes") - public Object getForInsert(Object owner, Map mergeMap, - SessionImplementor session) throws HibernateException { - final PersistentStoreAdapter adapter = StoreUtil - .getPersistentStoreAdapter((EObject) owner); + public Object getForInsert(Object owner, Map mergeMap, SessionImplementor session) + throws HibernateException { + final PersistentStoreAdapter adapter = StoreUtil.getPersistentStoreAdapter((EObject) owner); final Object value = adapter.getStoreCollection(eFeature); if (value != null) { return value; @@ -246,8 +234,7 @@ public class EListPropertyHandler implements Getter, Setter, PropertyAccessor, // force the estore to create a list, otherwise the .get // will return a null value. if (eStore.size((InternalEObject) owner, eFeature) != -1) { - obj = eStore.get((InternalEObject) owner, eFeature, - EStore.NO_INDEX); + obj = eStore.get((InternalEObject) owner, eFeature, EStore.NO_INDEX); } } @@ -270,14 +257,10 @@ public class EListPropertyHandler implements Getter, Setter, PropertyAccessor, if (object instanceof EObject) { final PersistentStoreAdapter elementAdapter = StoreUtil .getPersistentStoreAdapter((EObject) object); - elementAdapter - .setSyntheticProperty( - StoreUtil - .getExtraLazyInverseIndexPropertyName(eFeature), - index); - elementAdapter.setSyntheticProperty(StoreUtil - .getExtraLazyInversePropertyName(eFeature), - owner); + elementAdapter.setSyntheticProperty( + StoreUtil.getExtraLazyInverseIndexPropertyName(eFeature), index); + elementAdapter.setSyntheticProperty( + StoreUtil.getExtraLazyInversePropertyName(eFeature), owner); } index++; } @@ -320,15 +303,14 @@ public class EListPropertyHandler implements Getter, Setter, PropertyAccessor, /* * (non-Javadoc) * - * @see org.hibernate.property.Setter#set(java.lang.Object, - * java.lang.Object, org.hibernate.engine.SessionFactoryImplementor) + * @see org.hibernate.property.Setter#set(java.lang.Object, java.lang.Object, + * org.hibernate.engine.SessionFactoryImplementor) */ @SuppressWarnings("rawtypes") - public void set(Object target, Object value, - SessionFactoryImplementor factory) throws HibernateException { + public void set(Object target, Object value, SessionFactoryImplementor factory) + throws HibernateException { - final PersistentStoreAdapter adapter = StoreUtil - .getPersistentStoreAdapter((EObject) target); + final PersistentStoreAdapter adapter = StoreUtil.getPersistentStoreAdapter((EObject) target); if (!adapter.isTargetCreatedByORM()) { adapter.addStoreCollection(eFeature, value); return; @@ -338,41 +320,32 @@ public class EListPropertyHandler implements Getter, Setter, PropertyAccessor, if (log.isDebugEnabled()) { log.debug("Dynamic elist, set using the esettings"); } - Object currentValue = EcoreAccess.getManyEFeatureValue(eFeature, - (BasicEObjectImpl) target); + Object currentValue = EcoreAccess.getManyEFeatureValue(eFeature, (BasicEObjectImpl) target); if (StoreUtil.isEStoreList(currentValue)) { final EStore eStore = ((InternalEObject) target).eStore(); if (eStore.size((InternalEObject) target, eFeature) != -1) { - currentValue = eStore.get((InternalEObject) target, - eFeature, EStore.NO_INDEX); + currentValue = eStore.get((InternalEObject) target, eFeature, EStore.NO_INDEX); } } // if currentvalue is not null then use the passed value - if (currentValue != null - && currentValue instanceof PersistableEList<?>) { - ((PersistableEList<?>) currentValue) - .replaceDelegate((List) value); + if (currentValue != null && currentValue instanceof PersistableEList<?>) { + ((PersistableEList<?>) currentValue).replaceDelegate((List) value); } else { if (value instanceof Map<?, ?>) { - EcoreAccess.setManyEFeatureValue( - eFeature, - createPersistableMap((InternalEObject) target, - eFeature, (Map<?, ?>) value), + EcoreAccess.setManyEFeatureValue(eFeature, + createPersistableMap((InternalEObject) target, eFeature, (Map<?, ?>) value), (BasicEObjectImpl) target); } else { - EcoreAccess.setManyEFeatureValue( - eFeature, - createPersistableList((InternalEObject) target, - eFeature, (List<?>) value), + EcoreAccess.setManyEFeatureValue(eFeature, + createPersistableList((InternalEObject) target, eFeature, (List<?>) value), (BasicEObjectImpl) target); } } if (log.isDebugEnabled()) { - log.debug("Set value " + value.getClass().getName() - + " for target " + target.getClass().getName() - + " field " + getFieldName(target)); + log.debug("Set value " + value.getClass().getName() + " for target " + + target.getClass().getName() + " field " + getFieldName(target)); } } else { @@ -382,8 +355,7 @@ public class EListPropertyHandler implements Getter, Setter, PropertyAccessor, // while there // are multiple implementors. FieldUtil does caching of fieldnames // and fields. - final Field javaField = FieldUtil.getField(target.getClass(), - getFieldName(target)); + final Field javaField = FieldUtil.getField(target.getClass(), getFieldName(target)); // do not set the java field if not present, but use the store // adapter @@ -404,63 +376,45 @@ public class EListPropertyHandler implements Getter, Setter, PropertyAccessor, // the delegating map was passed to hibernate, now getting it // back if (value instanceof EMap.InternalMapView<?, ?> - && (currentValue == ((EMap.InternalMapView<?, ?>) value) - .eMap())) { + && (currentValue == ((EMap.InternalMapView<?, ?>) value).eMap())) { return; } // already handled if (currentValue instanceof PersistableDelegateList<?> - && value == ((PersistableDelegateList<?>) currentValue) - .getDelegate()) { + && value == ((PersistableDelegateList<?>) currentValue).getDelegate()) { return; } // the follow 3 if statements handle the refresh action, the // underlying orm // collection is replaced - if (currentValue != null - && currentValue instanceof PersistableEList<?> - && value != ((PersistableEList<?>) currentValue) - .getDelegate()) { - ((PersistableEList<?>) currentValue) - .replaceDelegate((List) value); - } else if (currentValue != null - && currentValue instanceof PersistableEMap<?, ?> - && value != ((PersistableEMap<?, ?>) currentValue) - .getDelegate()) { - ((PersistableEMap<?, ?>) currentValue) - .replaceDelegate(value); - } else if (currentValue != null - && currentValue instanceof MapPersistableEMap<?, ?> - && value != ((MapPersistableEMap<?, ?>) currentValue) - .getORMMapDelegate()) { - ((PersistableEMap<?, ?>) currentValue) - .replaceDelegate(value); + if (currentValue != null && currentValue instanceof PersistableEList<?> + && value != ((PersistableEList<?>) currentValue).getDelegate()) { + ((PersistableEList<?>) currentValue).replaceDelegate((List) value); + } else if (currentValue != null && currentValue instanceof PersistableEMap<?, ?> + && value != ((PersistableEMap<?, ?>) currentValue).getDelegate()) { + ((PersistableEMap<?, ?>) currentValue).replaceDelegate(value); + } else if (currentValue != null && currentValue instanceof MapPersistableEMap<?, ?> + && value != ((MapPersistableEMap<?, ?>) currentValue).getORMMapDelegate()) { + ((PersistableEMap<?, ?>) currentValue).replaceDelegate(value); } else { // then wrap the hibernate collection if (value instanceof Map<?, ?>) { - javaField.set( - target, - createPersistableMap((InternalEObject) target, - eFeature, (Map<?, ?>) value)); + javaField.set(target, + createPersistableMap((InternalEObject) target, eFeature, (Map<?, ?>) value)); } else { - javaField.set( - target, - createPersistableList((InternalEObject) target, - eFeature, (List<?>) value)); + javaField.set(target, + createPersistableList((InternalEObject) target, eFeature, (List<?>) value)); } } if (log.isDebugEnabled()) { - log.debug("Set value " + value.getClass().getName() - + " for target " + target.getClass().getName() - + " field " + getFieldName(target)); + log.debug("Set value " + value.getClass().getName() + " for target " + + target.getClass().getName() + " field " + getFieldName(target)); } } catch (Exception e) { throw new HbMapperException("The field " - + (javaField != null ? javaField.getName() - : getFieldName(target)) - + " can not be set using object " - + value.getClass().getName() + " on target " + + (javaField != null ? javaField.getName() : getFieldName(target)) + + " can not be set using object " + value.getClass().getName() + " on target " + target.getClass().getName(), e); } } @@ -469,22 +423,21 @@ public class EListPropertyHandler implements Getter, Setter, PropertyAccessor, /** * Create a EMap. Create method can be overridden */ - protected EList<?> createPersistableMap(InternalEObject target, - EStructuralFeature estruct, Map<?, ?> map) { + protected EList<?> createPersistableMap(InternalEObject target, EStructuralFeature estruct, + Map<?, ?> map) { final EReference eref = (EReference) estruct; if (log.isDebugEnabled()) { log.debug("Detected EMAP for " + estruct.getName()); } assert (isAMap); assert (newEMapMapping); - return getExtensionManager().getExtension( - MapHibernatePersistableEMap.class, + return getExtensionManager().getExtension(MapHibernatePersistableEMap.class, new Object[] { target, eref, map }); } /** Creates a persistablemap or list */ - protected EList<?> createPersistableList(InternalEObject target, - EStructuralFeature estruct, List<?> list) { + protected EList<?> createPersistableList(InternalEObject target, EStructuralFeature estruct, + List<?> list) { if (estruct instanceof EReference) { final EReference eref = (EReference) estruct; // the test for emap checks: the entry class must have a @@ -496,23 +449,19 @@ public class EListPropertyHandler implements Getter, Setter, PropertyAccessor, log.debug("Detected EMAP for " + estruct.getName()); } if (extraLazy) { - return getExtensionManager().getExtension( - HbExtraLazyPersistableEMap.class, + return getExtensionManager().getExtension(HbExtraLazyPersistableEMap.class, new Object[] { target, eref, list }); } else { - return getExtensionManager().getExtension( - HibernatePersistableEMap.class, + return getExtensionManager().getExtension(HibernatePersistableEMap.class, new Object[] { target, eref, list }); } } } if (extraLazy) { - return getExtensionManager().getExtension( - HbExtraLazyPersistableEList.class, + return getExtensionManager().getExtension(HbExtraLazyPersistableEList.class, new Object[] { target, estruct, list }); } - return getExtensionManager().getExtension( - HibernatePersistableEList.class, + return getExtensionManager().getExtension(HibernatePersistableEList.class, new Object[] { target, estruct, list }); } @@ -529,7 +478,7 @@ public class EListPropertyHandler implements Getter, Setter, PropertyAccessor, /** * @param extensionManager - * the extensionManager to set + * the extensionManager to set */ public void setExtensionManager(ExtensionManager extensionManager) { this.extensionManager = extensionManager; diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/property/EReferencePropertyHandler.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/property/EReferencePropertyHandler.java index 365448289..5ad25125b 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/property/EReferencePropertyHandler.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/property/EReferencePropertyHandler.java @@ -35,17 +35,15 @@ import org.hibernate.property.Setter; import org.hibernate.proxy.HibernateProxy; /** - * Implements the getter for an EReference field. Normally uses the eget/eset - * methods with bidirectional relations the handling is a bit different using - * eInverseRemove and eInverseAdd. This class implements both the getter, setter - * and propertyaccessor interfaces. When the getGetter and getSetter methods are - * called it returns itself. + * Implements the getter for an EReference field. Normally uses the eget/eset methods with + * bidirectional relations the handling is a bit different using eInverseRemove and eInverseAdd. + * This class implements both the getter, setter and propertyaccessor interfaces. When the getGetter + * and getSetter methods are called it returns itself. * * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> * @version $Revision: 1.21 $ */ -public class EReferencePropertyHandler implements Getter, Setter, - PropertyAccessor, ExtensionPoint { +public class EReferencePropertyHandler implements Getter, Setter, PropertyAccessor, ExtensionPoint { /** * Serial version id @@ -69,8 +67,8 @@ public class EReferencePropertyHandler implements Getter, Setter, this.eReference = eReference; final EClass eClass = eReference.getEContainingClass(); featureId = eClass.getFeatureID(eReference); - isBidirectional = (eReference.getEOpposite() != null && !eReference - .getEOpposite().isTransient()); + isBidirectional = (eReference.getEOpposite() != null && !eReference.getEOpposite() + .isTransient()); if (log.isDebugEnabled()) { log.debug("Created getter/setter for " + StoreUtil.toString(eReference)); } @@ -83,12 +81,10 @@ public class EReferencePropertyHandler implements Getter, Setter, /* * (non-Javadoc) * - * @see org.hibernate.property.PropertyAccessor#getGetter(java.lang.Class, - * java.lang.String) + * @see org.hibernate.property.PropertyAccessor#getGetter(java.lang.Class, java.lang.String) */ @SuppressWarnings("rawtypes") - public Getter getGetter(Class theClass, String propertyName) - throws PropertyNotFoundException { + public Getter getGetter(Class theClass, String propertyName) throws PropertyNotFoundException { return this; } @@ -104,12 +100,10 @@ public class EReferencePropertyHandler implements Getter, Setter, /* * (non-Javadoc) * - * @see org.hibernate.property.PropertyAccessor#getSetter(java.lang.Class, - * java.lang.String) + * @see org.hibernate.property.PropertyAccessor#getSetter(java.lang.Class, java.lang.String) */ @SuppressWarnings("rawtypes") - public Setter getSetter(Class theClass, String propertyName) - throws PropertyNotFoundException { + public Setter getSetter(Class theClass, String propertyName) throws PropertyNotFoundException { return this; } @@ -135,32 +129,30 @@ public class EReferencePropertyHandler implements Getter, Setter, /* * (non-Javadoc) * - * @see org.hibernate.property.Getter#getForInsert(java.lang.Object, - * java.util.Map, org.hibernate.engine.SessionImplementor) + * @see org.hibernate.property.Getter#getForInsert(java.lang.Object, java.util.Map, + * org.hibernate.engine.SessionImplementor) */ @SuppressWarnings("rawtypes") - public Object getForInsert(Object owner, Map mergeMap, - SessionImplementor session) throws HibernateException { + public Object getForInsert(Object owner, Map mergeMap, SessionImplementor session) + throws HibernateException { return get(owner); } /* * (non-Javadoc) * - * @see org.hibernate.property.Setter#set(java.lang.Object, - * java.lang.Object, org.hibernate.engine.SessionFactoryImplementor) + * @see org.hibernate.property.Setter#set(java.lang.Object, java.lang.Object, + * org.hibernate.engine.SessionFactoryImplementor) */ - public void set(Object target, Object value, - SessionFactoryImplementor factory) throws HibernateException { + public void set(Object target, Object value, SessionFactoryImplementor factory) + throws HibernateException { final Object curValue = get(target); if (isId()) { IdentifierCacheHandler.getInstance().setID(target, value); } - if (isBidirectional - || (target instanceof DynamicEObjectImpl && eReference - .isContainment())) { + if (isBidirectional || (target instanceof DynamicEObjectImpl && eReference.isContainment())) { // these are handled a bit differently because // the opposite should not be set, this is // done by hb @@ -175,17 +167,14 @@ public class EReferencePropertyHandler implements Getter, Setter, // opposite if (value == null) { // remove final NotificationChain nots = ((InternalEObject) target) - .eInverseRemove((InternalEObject) curValue, - featureId, eReference.getEType() - .getInstanceClass(), null); + .eInverseRemove((InternalEObject) curValue, featureId, eReference.getEType() + .getInstanceClass(), null); if (nots != null) { nots.dispatch(); } } else { - final NotificationChain nots = ((InternalEObject) target) - .eInverseAdd((InternalEObject) value, featureId, - eReference.getEType().getInstanceClass(), - null); + final NotificationChain nots = ((InternalEObject) target).eInverseAdd( + (InternalEObject) value, featureId, eReference.getEType().getInstanceClass(), null); if (nots != null) { nots.dispatch(); } @@ -200,13 +189,11 @@ public class EReferencePropertyHandler implements Getter, Setter, } final EObject eobj = (EObject) target; Resource res = eobj.eResource(); - if (value != null && res instanceof HibernateResource - && ((EObject) value).eResource() == null) { + if (value != null && res instanceof HibernateResource && ((EObject) value).eResource() == null) { final boolean loading = ((HibernateResource) res).isLoading(); try { ((HibernateResource) res).setIsLoading(true); - ((HibernateResource) res).addToContentOrAttach( - (InternalEObject) value, eReference); + ((HibernateResource) res).addToContentOrAttach((InternalEObject) value, eReference); } finally { ((HibernateResource) res).setIsLoading(loading); } diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/property/EcoreAccess.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/property/EcoreAccess.java index 56a50970d..4497a6950 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/property/EcoreAccess.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/property/EcoreAccess.java @@ -32,45 +32,38 @@ public class EcoreAccess { /** Return the DynamicValueHolder */ public static DynamicValueHolder getValueHolder(BasicEObjectImpl deo) { - if (deo instanceof DynamicValueHolder - && !(deo instanceof DynamicEObjectImpl)) { + if (deo instanceof DynamicValueHolder && !(deo instanceof DynamicEObjectImpl)) { return (DynamicValueHolder) deo; } - return (DynamicValueHolder) FieldUtil - .callMethod(deo, "eSettings", null); + return (DynamicValueHolder) FieldUtil.callMethod(deo, "eSettings", null); } /** Sets an elist using the passed feature */ - public static void setManyEFeatureValue(EStructuralFeature eFeature, - Object value, BasicEObjectImpl owner) { + public static void setManyEFeatureValue(EStructuralFeature eFeature, Object value, + BasicEObjectImpl owner) { final DynamicValueHolder dvh = getValueHolder(owner); dvh.dynamicSet(getFeatureId(owner, eFeature), value); } /** Gets an elist using the passed feature */ - public static EList<?> getManyEFeatureValue(EStructuralFeature eFeature, - BasicEObjectImpl owner) { + public static EList<?> getManyEFeatureValue(EStructuralFeature eFeature, BasicEObjectImpl owner) { final DynamicValueHolder dvh = getValueHolder(owner); return (EList<?>) dvh.dynamicGet(getFeatureId(owner, eFeature)); } - public static int getFeatureId(BasicEObjectImpl owner, - EStructuralFeature eFeature) { + public static int getFeatureId(BasicEObjectImpl owner, EStructuralFeature eFeature) { int featureId = owner.eClass().getFeatureID(eFeature); if (!isStaticFeature(eFeature, owner)) { - final int staticFeatureCount = (Integer) FieldUtil.callMethod( - owner, "eStaticFeatureCount", null); + final int staticFeatureCount = (Integer) FieldUtil.callMethod(owner, "eStaticFeatureCount", + null); featureId = featureId - staticFeatureCount; } return featureId; } /** Determines if a passed feature is a static feature */ - public static boolean isStaticFeature(EStructuralFeature eFeature, - BasicEObjectImpl owner) { - Integer staticFeatureCount = (Integer) FieldUtil.callMethod(owner, - "eStaticFeatureCount", null); - return owner.eClass().getFeatureID(eFeature) < staticFeatureCount - .intValue(); + public static boolean isStaticFeature(EStructuralFeature eFeature, BasicEObjectImpl owner) { + Integer staticFeatureCount = (Integer) FieldUtil.callMethod(owner, "eStaticFeatureCount", null); + return owner.eClass().getFeatureID(eFeature) < staticFeatureCount.intValue(); } }
\ No newline at end of file diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/property/FeatureMapEntryFeatureURIPropertyHandler.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/property/FeatureMapEntryFeatureURIPropertyHandler.java index 841663bbd..7dd093179 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/property/FeatureMapEntryFeatureURIPropertyHandler.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/property/FeatureMapEntryFeatureURIPropertyHandler.java @@ -33,14 +33,13 @@ import org.hibernate.property.PropertyAccessor; import org.hibernate.property.Setter; /** - * Handles the string representation of the feature of the feature map entry in - * the database. + * Handles the string representation of the feature of the feature map entry in the database. * * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> * @version $Revision: 1.8 $ */ -public class FeatureMapEntryFeatureURIPropertyHandler implements Getter, - Setter, PropertyAccessor, ExtensionPoint { +public class FeatureMapEntryFeatureURIPropertyHandler implements Getter, Setter, PropertyAccessor, + ExtensionPoint { /** * Generated Version ID */ @@ -49,12 +48,10 @@ public class FeatureMapEntryFeatureURIPropertyHandler implements Getter, /* * (non-Javadoc) * - * @see org.hibernate.property.PropertyAccessor#getGetter(java.lang.Class, - * java.lang.String) + * @see org.hibernate.property.PropertyAccessor#getGetter(java.lang.Class, java.lang.String) */ @SuppressWarnings("rawtypes") - public Getter getGetter(Class theClass, String propertyName) - throws PropertyNotFoundException { + public Getter getGetter(Class theClass, String propertyName) throws PropertyNotFoundException { return this; } @@ -70,12 +67,10 @@ public class FeatureMapEntryFeatureURIPropertyHandler implements Getter, /* * (non-Javadoc) * - * @see org.hibernate.property.PropertyAccessor#getSetter(java.lang.Class, - * java.lang.String) + * @see org.hibernate.property.PropertyAccessor#getSetter(java.lang.Class, java.lang.String) */ @SuppressWarnings("rawtypes") - public Setter getSetter(Class theClass, String propertyName) - throws PropertyNotFoundException { + public Setter getSetter(Class theClass, String propertyName) throws PropertyNotFoundException { return this; } @@ -85,8 +80,7 @@ public class FeatureMapEntryFeatureURIPropertyHandler implements Getter, public Object get(Object owner) throws HibernateException { if (!(owner instanceof HibernateFeatureMapEntry)) { final FeatureMap.Entry smf = (FeatureMap.Entry) owner; - return StoreUtil.structuralFeatureToString(smf - .getEStructuralFeature()); + return StoreUtil.structuralFeatureToString(smf.getEStructuralFeature()); } final HibernateFeatureMapEntry fme = (HibernateFeatureMapEntry) owner; return fme.getFeatureURI(); @@ -96,8 +90,8 @@ public class FeatureMapEntryFeatureURIPropertyHandler implements Getter, * Reads the version from the versioncache */ @SuppressWarnings("rawtypes") - public Object getForInsert(Object owner, Map mergeMap, - SessionImplementor session) throws HibernateException { + public Object getForInsert(Object owner, Map mergeMap, SessionImplementor session) + throws HibernateException { return get(owner); } @@ -126,8 +120,8 @@ public class FeatureMapEntryFeatureURIPropertyHandler implements Getter, } /** Sets the version in the internal version cache */ - public void set(Object target, Object value, - SessionFactoryImplementor factory) throws HibernateException { + public void set(Object target, Object value, SessionFactoryImplementor factory) + throws HibernateException { if (!(target instanceof HibernateFeatureMapEntry)) { // do nothing as value has not change... return; diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/property/FeatureMapEntryPropertyHandler.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/property/FeatureMapEntryPropertyHandler.java index eedda6934..fbca1f2ec 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/property/FeatureMapEntryPropertyHandler.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/property/FeatureMapEntryPropertyHandler.java @@ -38,15 +38,14 @@ import org.hibernate.property.Setter; /** * Implements the getter/setter for the featuremap entry. * - * This class implements both the getter, setter and propertyaccessor - * interfaces. When the getGetter and getSetter methods are called it returns - * itself. + * This class implements both the getter, setter and propertyaccessor interfaces. When the getGetter + * and getSetter methods are called it returns itself. * * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> * @version $Revision: 1.9 $ */ -public class FeatureMapEntryPropertyHandler implements Getter, Setter, - PropertyAccessor, ExtensionPoint { +public class FeatureMapEntryPropertyHandler implements Getter, Setter, PropertyAccessor, + ExtensionPoint { /** * Generated Version ID @@ -54,8 +53,7 @@ public class FeatureMapEntryPropertyHandler implements Getter, Setter, private static final long serialVersionUID = -2659637883475733107L; /** The logger */ - private static Log log = LogFactory - .getLog(FeatureMapEntryPropertyHandler.class); + private static Log log = LogFactory.getLog(FeatureMapEntryPropertyHandler.class); /** The feature */ protected EStructuralFeature eFeature; @@ -71,24 +69,20 @@ public class FeatureMapEntryPropertyHandler implements Getter, Setter, /* * (non-Javadoc) * - * @see org.hibernate.property.PropertyAccessor#getGetter(java.lang.Class, - * java.lang.String) + * @see org.hibernate.property.PropertyAccessor#getGetter(java.lang.Class, java.lang.String) */ @SuppressWarnings("rawtypes") - public Getter getGetter(Class theClass, String propertyName) - throws PropertyNotFoundException { + public Getter getGetter(Class theClass, String propertyName) throws PropertyNotFoundException { return this; } /* * (non-Javadoc) * - * @see org.hibernate.property.PropertyAccessor#getSetter(java.lang.Class, - * java.lang.String) + * @see org.hibernate.property.PropertyAccessor#getSetter(java.lang.Class, java.lang.String) */ @SuppressWarnings("rawtypes") - public Setter getSetter(Class theClass, String propertyName) - throws PropertyNotFoundException { + public Setter getSetter(Class theClass, String propertyName) throws PropertyNotFoundException { return this; } @@ -123,12 +117,12 @@ public class FeatureMapEntryPropertyHandler implements Getter, Setter, /* * (non-Javadoc) * - * @see org.hibernate.property.Getter#getForInsert(java.lang.Object, - * java.util.Map, org.hibernate.engine.SessionImplementor) + * @see org.hibernate.property.Getter#getForInsert(java.lang.Object, java.util.Map, + * org.hibernate.engine.SessionImplementor) */ @SuppressWarnings("rawtypes") - public Object getForInsert(Object owner, Map mergeMap, - SessionImplementor session) throws HibernateException { + public Object getForInsert(Object owner, Map mergeMap, SessionImplementor session) + throws HibernateException { final Object value = get(owner); return value; } @@ -136,11 +130,11 @@ public class FeatureMapEntryPropertyHandler implements Getter, Setter, /* * (non-Javadoc) * - * @see org.hibernate.property.Setter#set(java.lang.Object, - * java.lang.Object, org.hibernate.engine.SessionFactoryImplementor) + * @see org.hibernate.property.Setter#set(java.lang.Object, java.lang.Object, + * org.hibernate.engine.SessionFactoryImplementor) */ - public void set(Object target, Object value, - SessionFactoryImplementor factory) throws HibernateException { + public void set(Object target, Object value, SessionFactoryImplementor factory) + throws HibernateException { if (!(target instanceof HibernateFeatureMapEntry)) { // happens during initial save, value has not changed do nothing! return; diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/property/FeatureMapPropertyHandler.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/property/FeatureMapPropertyHandler.java index af222c751..9e63ed45b 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/property/FeatureMapPropertyHandler.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/property/FeatureMapPropertyHandler.java @@ -32,14 +32,15 @@ import org.eclipse.emf.teneo.util.AssertUtil; import org.eclipse.emf.teneo.util.StoreUtil; /** - * Implements the accessor for EMF FeatureMap members for Hibernate. Overrides the createPersistableList to create a - * HibernatePersistableFeatureMap instead of a normal list. + * Implements the accessor for EMF FeatureMap members for Hibernate. Overrides the + * createPersistableList to create a HibernatePersistableFeatureMap instead of a normal list. * * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> * @version $Revision: 1.10 $ */ @SuppressWarnings("unchecked") -public class FeatureMapPropertyHandler extends EListPropertyHandler implements ExtensionPoint, ExtensionManagerAware { +public class FeatureMapPropertyHandler extends EListPropertyHandler implements ExtensionPoint, + ExtensionManagerAware { /** * Generated Serial Version ID */ @@ -48,14 +49,15 @@ public class FeatureMapPropertyHandler extends EListPropertyHandler implements E /** Initialize this instance */ public void initialize(EStructuralFeature eFeature) { super.initialize(eFeature, false, false); - AssertUtil.assertTrue("Is not a featuremap feature " + StoreUtil.toString(eFeature), FeatureMapUtil - .isFeatureMap(eFeature)); + AssertUtil.assertTrue("Is not a featuremap feature " + StoreUtil.toString(eFeature), + FeatureMapUtil.isFeatureMap(eFeature)); } /** Create method can be overridden */ @SuppressWarnings("rawtypes") @Override - protected EList<?> createPersistableList(InternalEObject target, EStructuralFeature estruct, List list) { + protected EList<?> createPersistableList(InternalEObject target, EStructuralFeature estruct, + List list) { return new HibernatePersistableFeatureMap(target, estruct, list); } @@ -67,7 +69,8 @@ public class FeatureMapPropertyHandler extends EListPropertyHandler implements E final FeatureMap featureMap = (FeatureMap) list; for (FeatureMap.Entry entry : featureMap) { final HibernateFeatureMapEntry fme = new HibernateFeatureMapEntry(); - fme.setFeatureValue(entry.getEStructuralFeature(), entry.getValue(), (FeatureMap.Internal) list); + fme.setFeatureValue(entry.getEStructuralFeature(), entry.getValue(), + (FeatureMap.Internal) list); result.add(fme); } return result; diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/property/SyntheticPropertyHandler.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/property/SyntheticPropertyHandler.java index 35ca65802..343de3124 100644 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/property/SyntheticPropertyHandler.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/property/SyntheticPropertyHandler.java @@ -32,20 +32,18 @@ import org.hibernate.property.PropertyAccessor; import org.hibernate.property.Setter; /** - * Is a getter and setter for EMF eattribute which uses eGet and eSet.Handles - * many==false properties. + * Is a getter and setter for EMF eattribute which uses eGet and eSet.Handles many==false + * properties. * - * This class implements both the getter, setter and propertyaccessor - * interfaces. When the getGetter and getSetter methods are called it returns - * itself. + * This class implements both the getter, setter and propertyaccessor interfaces. When the getGetter + * and getSetter methods are called it returns itself. * * This accessor also handles arrays of primitive types. * * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> * @version $Revision: 1.5 $ */ -public class SyntheticPropertyHandler implements Getter, Setter, - PropertyAccessor { +public class SyntheticPropertyHandler implements Getter, Setter, PropertyAccessor { /** * Generated Serial Version ID @@ -65,12 +63,10 @@ public class SyntheticPropertyHandler implements Getter, Setter, /* * (non-Javadoc) * - * @see org.hibernate.property.PropertyAccessor#getGetter(java.lang.Class, - * java.lang.String) + * @see org.hibernate.property.PropertyAccessor#getGetter(java.lang.Class, java.lang.String) */ @SuppressWarnings("rawtypes") - public Getter getGetter(Class theClass, String propertyName) - throws PropertyNotFoundException { + public Getter getGetter(Class theClass, String propertyName) throws PropertyNotFoundException { return this; } @@ -86,12 +82,10 @@ public class SyntheticPropertyHandler implements Getter, Setter, /* * (non-Javadoc) * - * @see org.hibernate.property.PropertyAccessor#getSetter(java.lang.Class, - * java.lang.String) + * @see org.hibernate.property.PropertyAccessor#getSetter(java.lang.Class, java.lang.String) */ @SuppressWarnings("rawtypes") - public Setter getSetter(Class theClass, String propertyName) - throws PropertyNotFoundException { + public Setter getSetter(Class theClass, String propertyName) throws PropertyNotFoundException { return this; } @@ -101,16 +95,15 @@ public class SyntheticPropertyHandler implements Getter, Setter, * @see org.hibernate.property.Getter#get(java.lang.Object) */ public Object get(Object owner) throws HibernateException { - final PersistentStoreAdapter adapter = StoreUtil - .getPersistentStoreAdapter((EObject) owner); + final PersistentStoreAdapter adapter = StoreUtil.getPersistentStoreAdapter((EObject) owner); return adapter.getSyntheticProperty(propertyName); } /* * (non-Javadoc) * - * @see org.hibernate.property.Getter#getForInsert(java.lang.Object, - * java.util.Map, org.hibernate.engine.SessionImplementor) + * @see org.hibernate.property.Getter#getForInsert(java.lang.Object, java.util.Map, + * org.hibernate.engine.SessionImplementor) */ @SuppressWarnings("rawtypes") public Object getForInsert(Object arg0, Map arg1, SessionImplementor arg2) @@ -149,13 +142,12 @@ public class SyntheticPropertyHandler implements Getter, Setter, /* * (non-Javadoc) * - * @see org.hibernate.property.Setter#set(java.lang.Object, - * java.lang.Object, org.hibernate.engine.SessionFactoryImplementor) + * @see org.hibernate.property.Setter#set(java.lang.Object, java.lang.Object, + * org.hibernate.engine.SessionFactoryImplementor) */ - public void set(Object target, Object value, - SessionFactoryImplementor factory) throws HibernateException { - final PersistentStoreAdapter adapter = StoreUtil - .getPersistentStoreAdapter((EObject) target); + public void set(Object target, Object value, SessionFactoryImplementor factory) + throws HibernateException { + final PersistentStoreAdapter adapter = StoreUtil.getPersistentStoreAdapter((EObject) target); adapter.setSyntheticProperty(propertyName, value); } }
\ No newline at end of file diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/property/VersionPropertyHandler.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/property/VersionPropertyHandler.java index 476c443bb..8c7bcd872 100755 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/property/VersionPropertyHandler.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/property/VersionPropertyHandler.java @@ -36,8 +36,7 @@ import org.hibernate.property.Setter; * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> * @version $Revision: 1.8 $ */ -public class VersionPropertyHandler implements Getter, Setter, - PropertyAccessor, ExtensionPoint { +public class VersionPropertyHandler implements Getter, Setter, PropertyAccessor, ExtensionPoint { /** * Generated Serial Version ID */ @@ -46,24 +45,20 @@ public class VersionPropertyHandler implements Getter, Setter, /* * (non-Javadoc) * - * @see org.hibernate.property.PropertyAccessor#getGetter(java.lang.Class, - * java.lang.String) + * @see org.hibernate.property.PropertyAccessor#getGetter(java.lang.Class, java.lang.String) */ @SuppressWarnings("rawtypes") - public Getter getGetter(Class theClass, String propertyName) - throws PropertyNotFoundException { + public Getter getGetter(Class theClass, String propertyName) throws PropertyNotFoundException { return this; } /* * (non-Javadoc) * - * @see org.hibernate.property.PropertyAccessor#getSetter(java.lang.Class, - * java.lang.String) + * @see org.hibernate.property.PropertyAccessor#getSetter(java.lang.Class, java.lang.String) */ @SuppressWarnings("rawtypes") - public Setter getSetter(Class theClass, String propertyName) - throws PropertyNotFoundException { + public Setter getSetter(Class theClass, String propertyName) throws PropertyNotFoundException { return this; } @@ -78,8 +73,8 @@ public class VersionPropertyHandler implements Getter, Setter, * Reads the version from the versioncache */ @SuppressWarnings("rawtypes") - public Object getForInsert(Object owner, Map mergeMap, - SessionImplementor session) throws HibernateException { + public Object getForInsert(Object owner, Map mergeMap, SessionImplementor session) + throws HibernateException { return IdentifierCacheHandler.getInstance().getVersion(owner); } @@ -117,8 +112,8 @@ public class VersionPropertyHandler implements Getter, Setter, } /** Sets the version in the internal version cache */ - public void set(Object target, Object value, - SessionFactoryImplementor factory) throws HibernateException { + public void set(Object target, Object value, SessionFactoryImplementor factory) + throws HibernateException { IdentifierCacheHandler.getInstance().setVersion(target, value); } }
\ No newline at end of file diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/property/WildCardAttributePropertyHandler.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/property/WildCardAttributePropertyHandler.java index 2269939af..a524d4a14 100644 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/property/WildCardAttributePropertyHandler.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/property/WildCardAttributePropertyHandler.java @@ -36,18 +36,17 @@ import org.hibernate.property.PropertyAccessor; import org.hibernate.property.Setter; /** - * Implements the getter/setter for a wild card EAttribute property. This type - * of property is used in a feature map created for wild cards. + * Implements the getter/setter for a wild card EAttribute property. This type of property is used + * in a feature map created for wild cards. * - * This class implements both the getter, setter and propertyaccessor - * interfaces. When the getGetter and getSetter methods are called it returns - * itself. + * This class implements both the getter, setter and propertyaccessor interfaces. When the getGetter + * and getSetter methods are called it returns itself. * * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> * @version $Revision: 1.3 $ */ -public class WildCardAttributePropertyHandler implements Getter, Setter, - PropertyAccessor, ExtensionPoint { +public class WildCardAttributePropertyHandler implements Getter, Setter, PropertyAccessor, + ExtensionPoint { /** * Generated Version ID @@ -57,24 +56,20 @@ public class WildCardAttributePropertyHandler implements Getter, Setter, /* * (non-Javadoc) * - * @see org.hibernate.property.PropertyAccessor#getGetter(java.lang.Class, - * java.lang.String) + * @see org.hibernate.property.PropertyAccessor#getGetter(java.lang.Class, java.lang.String) */ @SuppressWarnings("rawtypes") - public Getter getGetter(Class theClass, String propertyName) - throws PropertyNotFoundException { + public Getter getGetter(Class theClass, String propertyName) throws PropertyNotFoundException { return this; } /* * (non-Javadoc) * - * @see org.hibernate.property.PropertyAccessor#getSetter(java.lang.Class, - * java.lang.String) + * @see org.hibernate.property.PropertyAccessor#getSetter(java.lang.Class, java.lang.String) */ @SuppressWarnings("rawtypes") - public Setter getSetter(Class theClass, String propertyName) - throws PropertyNotFoundException { + public Setter getSetter(Class theClass, String propertyName) throws PropertyNotFoundException { return this; } @@ -104,20 +99,20 @@ public class WildCardAttributePropertyHandler implements Getter, Setter, } final EAttribute eAttribute = (EAttribute) eFeature; final EDataType eDataType = eAttribute.getEAttributeType(); - final String valueString = eDataType.getEPackage() - .getEFactoryInstance().convertToString(eDataType, value); + final String valueString = eDataType.getEPackage().getEFactoryInstance() + .convertToString(eDataType, value); return valueString; } /* * (non-Javadoc) * - * @see org.hibernate.property.Getter#getForInsert(java.lang.Object, - * java.util.Map, org.hibernate.engine.SessionImplementor) + * @see org.hibernate.property.Getter#getForInsert(java.lang.Object, java.util.Map, + * org.hibernate.engine.SessionImplementor) */ @SuppressWarnings("rawtypes") - public Object getForInsert(Object owner, Map mergeMap, - SessionImplementor session) throws HibernateException { + public Object getForInsert(Object owner, Map mergeMap, SessionImplementor session) + throws HibernateException { final Object value = get(owner); return value; } @@ -134,11 +129,11 @@ public class WildCardAttributePropertyHandler implements Getter, Setter, /* * (non-Javadoc) * - * @see org.hibernate.property.Setter#set(java.lang.Object, - * java.lang.Object, org.hibernate.engine.SessionFactoryImplementor) + * @see org.hibernate.property.Setter#set(java.lang.Object, java.lang.Object, + * org.hibernate.engine.SessionFactoryImplementor) */ - public void set(Object target, Object value, - SessionFactoryImplementor factory) throws HibernateException { + public void set(Object target, Object value, SessionFactoryImplementor factory) + throws HibernateException { if (!(target instanceof HibernateFeatureMapEntry)) { // happens during initial save return; diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/property/WildCardReferencePropertyHandler.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/property/WildCardReferencePropertyHandler.java index d93554469..48382f2d3 100644 --- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/property/WildCardReferencePropertyHandler.java +++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/mapping/property/WildCardReferencePropertyHandler.java @@ -33,18 +33,17 @@ import org.hibernate.property.PropertyAccessor; import org.hibernate.property.Setter; /** - * Implements the getter/setter for a wild card reference property. This type of - * property is used in a feature map created for wild cards. + * Implements the getter/setter for a wild card reference property. This type of property is used in + * a feature map created for wild cards. * - * This class implements both the getter, setter and propertyaccessor - * interfaces. When the getGetter and getSetter methods are called it returns - * itself. + * This class implements both the getter, setter and propertyaccessor interfaces. When the getGetter + * and getSetter methods are called it returns itself. * * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> * @version $Revision: 1.3 $ */ -public class WildCardReferencePropertyHandler implements Getter, Setter, - PropertyAccessor, ExtensionPoint { +public class WildCardReferencePropertyHandler implements Getter, Setter, PropertyAccessor, + ExtensionPoint { /** * Generated Version ID @@ -54,24 +53,20 @@ public class WildCardReferencePropertyHandler implements Getter, Setter, /* * (non-Javadoc) * - * @see org.hibernate.property.PropertyAccessor#getGetter(java.lang.Class, - * java.lang.String) + * @see org.hibernate.property.PropertyAccessor#getGetter(java.lang.Class, java.lang.String) */ @SuppressWarnings("rawtypes") - public Getter getGetter(Class theClass, String propertyName) - throws PropertyNotFoundException { + public Getter getGetter(Class theClass, String propertyName) throws PropertyNotFoundException { return this; } /* * (non-Javadoc) * - * @see org.hibernate.property.PropertyAccessor#getSetter(java.lang.Class, - * java.lang.String) + * @see org.hibernate.property.PropertyAccessor#getSetter(java.lang.Class, java.lang.String) */ @SuppressWarnings("rawtypes") - public Setter getSetter(Class theClass, String propertyName) - throws PropertyNotFoundException { + public Setter getSetter(Class theClass, String propertyName) throws PropertyNotFoundException { return this; } @@ -108,12 +103,12 @@ public class WildCardReferencePropertyHandler implements Getter, Setter, /* * (non-Javadoc) * - * @see org.hibernate.property.Getter#getForInsert(java.lang.Object, - * java.util.Map, org.hibernate.engine.SessionImplementor) + * @see org.hibernate.property.Getter#getForInsert(java.lang.Object, java.util.Map, + * org.hibernate.engine.SessionImplementor) */ @SuppressWarnings("rawtypes") - public Object getForInsert(Object owner, Map mergeMap, - SessionImplementor session) throws HibernateException { + public Object getForInsert(Object owner, Map mergeMap, SessionImplementor session) + throws HibernateException { final Object value = get(owner); return value; } @@ -121,11 +116,11 @@ public class WildCardReferencePropertyHandler implements Getter, Setter, /* * (non-Javadoc) * - * @see org.hibernate.property.Setter#set(java.lang.Object, - * java.lang.Object, org.hibernate.engine.SessionFactoryImplementor) + * @see org.hibernate.property.Setter#set(java.lang.Object, java.lang.Object, + * org.hibernate.engine.SessionFactoryImplementor) */ - public void set(Object target, Object value, - SessionFactoryImplementor factory) throws HibernateException { + public void set(Object target, Object value, SessionFactoryImplementor factory) + throws HibernateException { if (!(target instanceof HibernateFeatureMapEntry)) { // happens during initial save, value has not changed do nothing return; |