Yes! I like this idea a lotfully. Good thinking :) ----- Original Message ----- From: "Jon Lipsky" <[EMAIL PROTECTED]> To: "Gavin King" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Thursday, October 17, 2002 3:58 PM Subject: Re: [Hibernate] ClobType
> Shouldn't it be possible to create wrapper reader/writer's for the real > reader/writers that implement some kind dirty checking? Perhaps the wrapper > reader/writer to read and write to an and from a char[] arrays, and then > when we really to to persist the Clob, the wrapper could then write the > char[] to the real writer.?.? > > > ----- Original Message ----- > From: "Gavin King" <[EMAIL PROTECTED]> > To: "Mark Woon" <[EMAIL PROTECTED]> > Cc: <[EMAIL PROTECTED]> > Sent: Thursday, October 17, 2002 7:35 AM > Subject: Re: [Hibernate] ClobType > > > > The fact that I don't know what I think is the main reason I've never > added > > a ClobType before. I'm assuming that the best way would be to somehow > > provide access to the JDBC Clob object (and similarly for Blobs). Is this > > possible? Do you need to provide a seperate Holder class? > > > > I like the reader/writer idea but the trouble with that is how on earth do > > you do dirty checking? Hibernate can't compare the reader to the writer to > > see if it changed..... > > > > ----- Original Message ----- > > From: "Mark Woon" <[EMAIL PROTECTED]> > > To: "Hibernate Mailing List" <[EMAIL PROTECTED]> > > Sent: Wednesday, October 16, 2002 6:11 PM > > Subject: [Hibernate] ClobType > > > > > > > Gavin, > > > > > > I know I've reported that Hibernate works with CLOB's, but I'm afraid > > > that I was wrong. Hibernate persists Strings into CLOB columns > > > perfectly fine, but reading it out of the db yields a null. I've added > > > a new ClobType to handle CLOB columns to treat them as Strings. I've > > > attached a diff and the new file. > > > > > > I'm not sure that this is the right thing to do, because some may want > > > direct access to the Clob object, or would prefer a Reader (in which > > > case the setter ought to be a Writer), which would be a lot more > > > complicated. If we go with the former, Hibernate would need to > > > implement it's own Clob object. What do you think? > > > > > > -Mark > > > > > > > > > > > > -------------------------------------------------------------------------- > -- > > ---- > > > > > > > ? build > > > ? patch.diff > > > ? cirrus/hibernate/type/ClobType.java > > > ? lib/j2ee.jar > > > ? lib/junit.jar > > > Index: cirrus/hibernate/Hibernate.java > > > =================================================================== > > > RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/Hibernate.java,v > > > retrieving revision 1.59 > > > diff -c -r1.59 Hibernate.java > > > *** cirrus/hibernate/Hibernate.java 5 Oct 2002 04:18:30 -0000 1.59 > > > --- cirrus/hibernate/Hibernate.java 16 Oct 2002 08:02:56 -0000 > > > *************** > > > *** 50,55 **** > > > --- 50,59 ---- > > > */ > > > public static final NullableType STRING = new StringType(); > > > /** > > > + * Hibernate <tt>clob</tt> type > > > + */ > > > + public static final NullableType CLOB = new ClobType(); > > > + /** > > > * Hibernate <tt>time</tt> type > > > */ > > > public static final NullableType TIME = new TimeType(); > > > Index: cirrus/hibernate/impl/SessionImpl.java > > > =================================================================== > > > RCS file: > > /cvsroot/hibernate/Hibernate/cirrus/hibernate/impl/SessionImpl.java,v > > > retrieving revision 1.128 > > > diff -c -r1.128 SessionImpl.java > > > *** cirrus/hibernate/impl/SessionImpl.java 15 Oct 2002 16:04:05 -0000 > > 1.128 > > > --- cirrus/hibernate/impl/SessionImpl.java 16 Oct 2002 08:03:04 -0000 > > > *************** > > > *** 1002,1008 **** > > > } > > > else if ( old!=null ) { > > > throw new HibernateException( > > > ! "Another object was associated with this id (the object with the given > > id was already loaded)" > > > ); > > > } > > > > > > --- 1002,1009 ---- > > > } > > > else if ( old!=null ) { > > > throw new HibernateException( > > > ! "Another object of " + object.getClass().toString() + > > > ! " has already been loaded with the id > " > > + id > > > ); > > > } > > > > > > Index: cirrus/hibernate/sql/OracleDialect.java > > > =================================================================== > > > RCS file: > > /cvsroot/hibernate/Hibernate/cirrus/hibernate/sql/OracleDialect.java,v > > > retrieving revision 1.25 > > > diff -c -r1.25 OracleDialect.java > > > *** cirrus/hibernate/sql/OracleDialect.java 2 Oct 2002 06:27:55 -0000 > 1.25 > > > --- cirrus/hibernate/sql/OracleDialect.java 16 Oct 2002 08:03:05 -0000 > > > *************** > > > *** 31,36 **** > > > --- 31,37 ---- > > > register( Types.TIMESTAMP, "DATE" ); > > > register( Types.VARBINARY, "RAW($l)" ); > > > register( Types.NUMERIC, "NUMBER(19, $l)" ); > > > + register( Types.CLOB, "CLOB" ); > > > > > > outerJoinGenerator = new OracleOuterJoinGenerator(); > > > > > > Index: cirrus/hibernate/type/TypeFactory.java > > > =================================================================== > > > RCS file: > > /cvsroot/hibernate/Hibernate/cirrus/hibernate/type/TypeFactory.java,v > > > retrieving revision 1.20 > > > diff -c -r1.20 TypeFactory.java > > > *** cirrus/hibernate/type/TypeFactory.java 5 Oct 2002 09:33:42 -0000 > 1.20 > > > --- cirrus/hibernate/type/TypeFactory.java 16 Oct 2002 08:03:06 -0000 > > > *************** > > > *** 39,44 **** > > > --- 39,45 ---- > > > basics.put( Hibernate.CHARACTER.getName(), Hibernate.CHARACTER); > > > basics.put( Hibernate.INTEGER.getName(), Hibernate.INTEGER); > > > basics.put( Hibernate.STRING.getName(), Hibernate.STRING); > > > + basics.put( Hibernate.CLOB.getName(), Hibernate.CLOB); > > > basics.put( Hibernate.DATE.getName(), Hibernate.DATE); > > > basics.put( Hibernate.TIME.getName(), Hibernate.TIME); > > > basics.put( Hibernate.TIMESTAMP.getName(), Hibernate.TIMESTAMP); > > > > > > > > > -------------------------------------------------------------------------- > -- > > ---- > > > > > > > //$Id: ClobType.java,v 1.17 2002/10/11 05:39:15 oneovthafew Exp $ > > > package cirrus.hibernate.type; > > > > > > import java.sql.Clob; > > > import java.sql.PreparedStatement; > > > import java.sql.ResultSet; > > > import java.sql.SQLException; > > > import java.sql.Types; > > > > > > public class ClobType extends ImmutableType implements DiscriminatorType > { > > > > > > public Object get(ResultSet rs, String name) throws SQLException { > > > Clob clob = rs.getClob(name); > > > if (clob != null) { > > > long len = clob.length(); > > > if (len > Integer.MAX_VALUE) { > > > long idx = 1; > > > StringBuffer buf = new StringBuffer(); > > > while (idx < len) { > > > long diff = len - idx; > > > if (diff > Integer.MAX_VALUE) { > > > buf.append(clob.getSubString(idx, Integer.MAX_VALUE)); > > > idx += Integer.MAX_VALUE; > > > } else { > > > buf.append(clob.getSubString(idx, (int)(diff + 1))); > > > idx += diff; > > > } > > > } > > > return buf.toString(); > > > } else { > > > return clob.getSubString(1, (int)len); > > > } > > > } > > > return null; > > > } > > > > > > public Class returnedClass() { > > > return String.class; > > > } > > > > > > public void set(PreparedStatement st, Object value, int index) throws > > SQLException { > > > st.setString(index, (String) value); > > > } > > > > > > public int sqlType() { > > > return Types.CLOB; > > > } > > > > > > public String getName() { return "clob"; } > > > > > > public String objectToSQLString(Object value) throws Exception { > > > return '\'' + (String) value + '\''; > > > } > > > > > > public Object stringToObject(String xml) throws Exception { > > > return xml; > > > } > > > > > > public boolean equals(Object x, Object y) { > > > if (x==y) return true; > > > if (x==null || y==null) return false; > > > // don't have to check class for String > > > return x.equals(y); > > > } > > > public String toXML(Object value) { > > > return (String) value; > > > } > > > } > > > > > > > > > > > ------------------------------------------------------- > > This sf.net email is sponsored by: viaVerio will pay you up to > > $1,000 for every account that you consolidate with us. > > http://ad.doubleclick.net/clk;4749864;7604308;v? > > http://www.viaverio.com/consolidator/osdn.cfm > > _______________________________________________ > > hibernate-devel mailing list > > [EMAIL PROTECTED] > > https://lists.sourceforge.net/lists/listinfo/hibernate-devel > > > > > > ------------------------------------------------------- > This sf.net email is sponsored by: viaVerio will pay you up to > $1,000 for every account that you consolidate with us. > http://ad.doubleclick.net/clk;4749864;7604308;v? > http://www.viaverio.com/consolidator/osdn.cfm > _______________________________________________ > hibernate-devel mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/hibernate-devel ------------------------------------------------------- This sf.net email is sponsored by: viaVerio will pay you up to $1,000 for every account that you consolidate with us. http://ad.doubleclick.net/clk;4749864;7604308;v? http://www.viaverio.com/consolidator/osdn.cfm _______________________________________________ hibernate-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/hibernate-devel