|
Hibernate example source code file (ClobTypeDescriptor.java)
The Hibernate ClobTypeDescriptor.java source code/* * 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.descriptor.java; import java.io.Serializable; import java.sql.Clob; import java.sql.SQLException; import java.util.Comparator; import org.hibernate.HibernateException; import org.hibernate.engine.jdbc.ClobProxy; import org.hibernate.engine.jdbc.WrappedClob; import org.hibernate.type.descriptor.CharacterStream; import org.hibernate.type.descriptor.WrapperOptions; /** * Descriptor for {@link Clob} handling. * <p/> * Note, {@link Clob clobs} really are mutable (their internal state can in fact be mutated). We simply * treat them as immutable because we cannot properly check them for changes nor deep copy them. * * @author Steve Ebersole */ public class ClobTypeDescriptor extends AbstractTypeDescriptor<Clob> { public static final ClobTypeDescriptor INSTANCE = new ClobTypeDescriptor(); public static class ClobMutabilityPlan implements MutabilityPlan<Clob> { public static final ClobMutabilityPlan INSTANCE = new ClobMutabilityPlan(); public boolean isMutable() { return false; } public Clob deepCopy(Clob value) { return value; } public Serializable disassemble(Clob value) { throw new UnsupportedOperationException( "Clobs are not cacheable" ); } public Clob assemble(Serializable cached) { throw new UnsupportedOperationException( "Clobs are not cacheable" ); } } public ClobTypeDescriptor() { super( Clob.class, ClobMutabilityPlan.INSTANCE ); } public String toString(Clob value) { try { return DataHelper.extractString( value.getCharacterStream() ); } catch ( SQLException e ) { throw new HibernateException( "Unable to access clob stream", e ); } } public Clob fromString(String string) { return ClobProxy.generateProxy( string ); } @Override @SuppressWarnings({ "unchecked" }) public Comparator<Clob> getComparator() { return IncomparableComparator.INSTANCE; } @Override public int extractHashCode(Clob value) { return System.identityHashCode( value ); } @Override public boolean areEqual(Clob one, Clob another) { return one == another; } @SuppressWarnings({ "unchecked" }) public <X> X unwrap(final Clob value, Class Other Hibernate examples (source code examples)Here is a short list of links related to this Hibernate ClobTypeDescriptor.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.