From 21c3a17d4c6edb889b77518b978e436004fa20ca Mon Sep 17 00:00:00 2001 From: Strong Liu Date: Thu, 18 Jul 2013 00:36:29 +0800 Subject: [PATCH] HHH-8336 remove deprecated types --- .../hibernate/type/AbstractBynaryType.java | 186 ------------- .../hibernate/type/AbstractCharArrayType.java | 120 --------- .../hibernate/type/AbstractComponentType.java | 37 --- .../org/hibernate/type/AbstractLobType.java | 100 ------- .../type/AbstractLongBinaryType.java | 47 ---- .../type/AbstractLongStringType.java | 94 ------- .../org/hibernate/type/ByteArrayBlobType.java | 193 -------------- .../org/hibernate/type/CharBooleanType.java | 60 ----- .../org/hibernate/type/ImmutableType.java | 58 ----- .../java/org/hibernate/type/MutableType.java | 61 ----- .../java/org/hibernate/type/NullableType.java | 244 ------------------ .../type/PrimitiveByteArrayBlobType.java | 46 ---- .../org/hibernate/type/StringClobType.java | 110 -------- .../type/descriptor/JdbcTypeNameMapper.java | 2 +- 14 files changed, 1 insertion(+), 1357 deletions(-) delete mode 100644 hibernate-core/src/main/java/org/hibernate/type/AbstractBynaryType.java delete mode 100644 hibernate-core/src/main/java/org/hibernate/type/AbstractCharArrayType.java delete mode 100644 hibernate-core/src/main/java/org/hibernate/type/AbstractComponentType.java delete mode 100644 hibernate-core/src/main/java/org/hibernate/type/AbstractLobType.java delete mode 100644 hibernate-core/src/main/java/org/hibernate/type/AbstractLongBinaryType.java delete mode 100644 hibernate-core/src/main/java/org/hibernate/type/AbstractLongStringType.java delete mode 100644 hibernate-core/src/main/java/org/hibernate/type/ByteArrayBlobType.java delete mode 100644 hibernate-core/src/main/java/org/hibernate/type/CharBooleanType.java delete mode 100644 hibernate-core/src/main/java/org/hibernate/type/ImmutableType.java delete mode 100644 hibernate-core/src/main/java/org/hibernate/type/MutableType.java delete mode 100644 hibernate-core/src/main/java/org/hibernate/type/NullableType.java delete mode 100644 hibernate-core/src/main/java/org/hibernate/type/PrimitiveByteArrayBlobType.java delete mode 100644 hibernate-core/src/main/java/org/hibernate/type/StringClobType.java diff --git a/hibernate-core/src/main/java/org/hibernate/type/AbstractBynaryType.java b/hibernate-core/src/main/java/org/hibernate/type/AbstractBynaryType.java deleted file mode 100644 index 05344d15c8..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/AbstractBynaryType.java +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * Copyright (c) 2010, Red Hat Inc. or third-party contributors as - * indicated by the @author tags or express copyright attribution - * statements applied by the authors. All third-party contributions are - * distributed under license by Red Hat Inc. - * - * This copyrighted material is made available to anyone wishing to use, modify, - * copy, or redistribute it subject to the terms and conditions of the GNU - * Lesser General Public License, as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this distribution; if not, write to: - * Free Software Foundation, Inc. - * 51 Franklin Street, Fifth Floor - * Boston, MA 02110-1301 USA - */ -package org.hibernate.type; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Types; -import java.util.Comparator; - -import org.hibernate.HibernateException; -import org.hibernate.cfg.Environment; -import org.hibernate.engine.spi.SessionImplementor; - -/** - * Logic to bind stream of byte into a VARBINARY - * - * @author Gavin King - * @author Emmanuel Bernard - * - * @deprecated Use the {@link AbstractStandardBasicType} approach instead - */ -public abstract class AbstractBynaryType extends MutableType implements VersionType, Comparator { - - /** - * Convert the byte[] into the expected object type - */ - abstract protected Object toExternalFormat(byte[] bytes); - - /** - * Convert the object into the internal byte[] representation - */ - abstract protected byte[] toInternalFormat(Object bytes); - - public void set(PreparedStatement st, Object value, int index) throws HibernateException, SQLException { - byte[] internalValue = toInternalFormat( value ); - if ( Environment.useStreamsForBinary() ) { - st.setBinaryStream( index, new ByteArrayInputStream( internalValue ), internalValue.length ); - } - else { - st.setBytes( index, internalValue ); - } - } - - public Object get(ResultSet rs, String name) throws HibernateException, SQLException { - - if ( Environment.useStreamsForBinary() ) { - - InputStream inputStream = rs.getBinaryStream(name); - - if (inputStream==null) return toExternalFormat( null ); // is this really necessary? - - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(2048); - byte[] buffer = new byte[2048]; - - try { - while (true) { - int amountRead = inputStream.read(buffer); - if (amountRead == -1) { - break; - } - outputStream.write(buffer, 0, amountRead); - } - - inputStream.close(); - outputStream.close(); - } - catch (IOException ioe) { - throw new HibernateException( "IOException occurred reading a binary value", ioe ); - } - - return toExternalFormat( outputStream.toByteArray() ); - - } - else { - return toExternalFormat( rs.getBytes(name) ); - } - } - - public int sqlType() { - return Types.VARBINARY; - } - - // VersionType impl ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Note : simply returns null for seed() and next() as the only known - // application of binary types for versioning is for use with the - // TIMESTAMP datatype supported by Sybase and SQL Server, which - // are completely db-generated values... - public Object seed(SessionImplementor session) { - return null; - } - - public Object next(Object current, SessionImplementor session) { - return current; - } - - public Comparator getComparator() { - return this; - } - - - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - public boolean isEqual(Object x, Object y) { - return x==y || ( x!=null && y!=null && java.util.Arrays.equals( toInternalFormat(x), toInternalFormat(y) ) ); - } - - public int getHashCode(Object x) { - byte[] bytes = toInternalFormat(x); - int hashCode = 1; - for ( int j=0; j ybytes.length ) return 1; - for ( int i=0; i ybytes[i] ) return 1; - } - return 0; - } - - public abstract String getName(); - - public String toString(Object val) { - byte[] bytes = toInternalFormat(val); - StringBuilder buf = new StringBuilder(); - for ( int i=0; i 0 ; i = reader.read( charbuf ) ) { - result.append( charbuf, 0, i ); - } - } - catch (IOException e) { - throw new SQLException( e.getMessage() ); - } - return result.toString(); - } - - public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws HibernateException, SQLException { - if ( value != null ) { - String string = (String) value; - StringReader reader = new StringReader( string ); - st.setCharacterStream( index, reader, string.length() ); - } - else { - st.setNull( index, sqlTypes()[0] ); - } - } - - public Object deepCopy(Object value) throws HibernateException { - //returning value should be OK since String are immutable - return value; - } - - public boolean isMutable() { - return false; - } - - public Serializable disassemble(Object value) throws HibernateException { - return (Serializable) value; - } - - public Object assemble(Serializable cached, Object owner) throws HibernateException { - return cached; - } - - public Object replace(Object original, Object target, Object owner) throws HibernateException { - return original; - } -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/JdbcTypeNameMapper.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/JdbcTypeNameMapper.java index 032dc07878..0f3d44c1c7 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/JdbcTypeNameMapper.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/JdbcTypeNameMapper.java @@ -41,7 +41,7 @@ import org.hibernate.internal.CoreMessageLogger; public class JdbcTypeNameMapper { private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, JdbcTypeNameMapper.class.getName()); - private static Map JDBC_TYPE_MAP = buildJdbcTypeMap(); + private static final Map JDBC_TYPE_MAP = buildJdbcTypeMap(); private static Map buildJdbcTypeMap() { HashMap map = new HashMap();