Skip to content

Commit

Permalink
HHH-7776 - Consolidate to/from string handling for types in StringRep…
Browse files Browse the repository at this point in the history
…resentableType
  • Loading branch information
sebersole committed Nov 13, 2012
1 parent 1b68eb1 commit 8b53e46
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 35 deletions.
Expand Up @@ -30,8 +30,6 @@
import java.sql.SQLException;
import java.util.Map;

import org.dom4j.Node;

import org.hibernate.Hibernate;
import org.hibernate.HibernateException;
import org.hibernate.MappingException;
Expand All @@ -40,7 +38,6 @@
import org.hibernate.engine.spi.Mapping;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.collections.ArrayHelper;
import org.hibernate.metamodel.spi.relational.Size;
import org.hibernate.type.descriptor.WrapperOptions;
Expand Down Expand Up @@ -79,14 +76,6 @@ public T fromStringValue(String xml) throws HibernateException {
return fromString( xml );
}

public String toXMLString(T value, SessionFactoryImplementor factory) throws HibernateException {
return toString( value );
}

public T fromXMLString(String xml, Mapping factory) throws HibernateException {
return StringHelper.isEmpty( xml ) ? null : fromStringValue( xml );
}

protected MutabilityPlan<T> getMutabilityPlan() {
return javaTypeDescriptor.getMutabilityPlan();
}
Expand Down Expand Up @@ -303,7 +292,7 @@ public SqlTypeDescriptor remapSqlTypeDescriptor(SqlTypeDescriptor sqlTypeDescrip

@SuppressWarnings({ "unchecked" })
protected final void nullSafeSet(PreparedStatement st, Object value, int index, WrapperOptions options) throws SQLException {
remapSqlTypeDescriptor( options ).getBinder( javaTypeDescriptor ).bind( st, ( T ) value, index, options );
remapSqlTypeDescriptor( options ).getBinder( javaTypeDescriptor ).bind( st, (T) value, index, options );
}

protected SqlTypeDescriptor remapSqlTypeDescriptor(WrapperOptions options) {
Expand Down Expand Up @@ -346,7 +335,7 @@ public final void beforeAssemble(Serializable cached, SessionImplementor session

public final Object hydrate(ResultSet rs, String[] names, SessionImplementor session, Object owner)
throws HibernateException, SQLException {
return nullSafeGet(rs, names, session, owner);
return nullSafeGet( rs, names, session, owner );
}

public final Object resolve(Object value, SessionImplementor session, Object owner) throws HibernateException {
Expand Down
12 changes: 1 addition & 11 deletions hibernate-core/src/main/java/org/hibernate/type/MetaType.java
Expand Up @@ -122,17 +122,7 @@ public void nullSafeSet(
}

public String toLoggableString(Object value, SessionFactoryImplementor factory) throws HibernateException {
return toXMLString(value, factory);
}

public String toXMLString(Object value, SessionFactoryImplementor factory)
throws HibernateException {
return (String) value; //value is the entity name
}

public Object fromXMLString(String xml, Mapping factory)
throws HibernateException {
return xml; //xml is the entity name
return value == null ? "<null>" : value.toString();
}

public String getName() {
Expand Down
Expand Up @@ -27,7 +27,6 @@
import java.sql.ResultSet;
import java.sql.SQLException;

import org.dom4j.Node;
import org.jboss.logging.Logger;

import org.hibernate.HibernateException;
Expand Down Expand Up @@ -207,15 +206,6 @@ public final Object nullSafeGet(ResultSet rs, String name, SessionImplementor se
return nullSafeGet( rs, name );
}

public final String toXMLString(Object value, SessionFactoryImplementor pc)
throws HibernateException {
return toString(value);
}

public final Object fromXMLString(String xml, Mapping factory) throws HibernateException {
return xml==null || xml.length()==0 ? null : fromStringValue(xml);
}

public final int getColumnSpan(Mapping session) {
return 1;
}
Expand All @@ -236,7 +226,7 @@ public Size[] defaultSizes(Mapping mapping) throws MappingException {

@Override
public boolean isEqual(Object x, Object y) {
return EqualsHelper.equals(x, y);
return EqualsHelper.equals( x, y );
}

public String toLoggableString(Object value, SessionFactoryImplementor factory) {
Expand Down

0 comments on commit 8b53e46

Please sign in to comment.