|
View:
New views
9 Messages
—
Rating Filter:
Alert me
|
|
|
Hibernate + Derby - Unable to determine stream header for hibernate type 'text'Hello all,
We have just started to look into Derby as our embedded DB for a desktop app version. Env: Hibernate 3.2 and Derby 10.5.1 I have defined a java string field of type 'text' in Hibernate Mapping (works great on Postgres 8.1 and Oracle 10g), and Hibernate's DerbyDialect generates a CLOB (255) column for that field in Derby I use Hibernate SessionFactory to generate Table schema, which is done without any error. But, when I try to save records in tables via Hibernate Session, I get the following exception: Note: If I change hibernate mapping to type 'string', then I dont get this error: java.lang.IllegalStateException: No context, unable to determine which stream header format to generate at org.apache.derby.iapi.types.ClobStreamHeaderGenerator.determineMode(Unknown Source) at org.apache.derby.iapi.types.ClobStreamHeaderGenerator.expectsCharCount(Unknown Source) at org.apache.derby.iapi.types.ReaderToUTF8Stream.fillBuffer(Unknown Source) at org.apache.derby.iapi.types.ReaderToUTF8Stream.read(Unknown Source) at java.io.DataInputStream.read(Unknown Source) at org.apache.derby.iapi.types.SQLClob.readExternal(Unknown Source) at org.apache.derby.iapi.types.SQLChar.getString(Unknown Source) at org.apache.derby.iapi.types.SQLClob.getClone(Unknown Source) at org.apache.derby.impl.sql.GenericParameter.getClone(Unknown Source) at org.apache.derby.impl.sql.GenericParameterValueSet.<init>(Unknown Source) at org.apache.derby.impl.sql.GenericParameterValueSet.getClone(Unknown Source) at org.apache.derby.impl.jdbc.EmbedPreparedStatement.addBatch(Unknown Source) at org.hibernate.jdbc.BatchingBatcher.addToBatch(BatchingBatcher.java:31) at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2252) at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2665) Also, I need to save it as type 'text' even though it gets saved as CLOB(255), as the CLOB column size can later be altered. What could be the cause? or changes needed? thanks all |
|
|
Re: Hibernate + Derby - Unable to determine stream header for hibernate type 'text'kashyup wrote:
> Hello all, > We have just started to look into Derby as our embedded DB for a desktop app > version. > > Env: Hibernate 3.2 and Derby 10.5.1 > > I have defined a java string field of type 'text' in Hibernate Mapping > (works great on Postgres 8.1 and Oracle 10g) > > I use Hibernate SessionFactory to generate Table schema, which is done > without any error. > > But, when I try to save records in tables via Hibernate Session, I get the > following exception: > Note: If I change hibernate mapping to type 'string', then I dont get this > error: > > java.lang.IllegalStateException: No context, unable to determine which > stream header format to generate > at > org.apache.derby.iapi.types.ClobStreamHeaderGenerator.determineMode(Unknown > Source) > at > org.apache.derby.iapi.types.ClobStreamHeaderGenerator.expectsCharCount(Unknown > Source) > at org.apache.derby.iapi.types.ReaderToUTF8Stream.fillBuffer(Unknown > Source) > at org.apache.derby.iapi.types.ReaderToUTF8Stream.read(Unknown Source) > at java.io.DataInputStream.read(Unknown Source) > at org.apache.derby.iapi.types.SQLClob.readExternal(Unknown Source) > at org.apache.derby.iapi.types.SQLChar.getString(Unknown Source) > at org.apache.derby.iapi.types.SQLClob.getClone(Unknown Source) > at org.apache.derby.impl.sql.GenericParameter.getClone(Unknown Source) > at org.apache.derby.impl.sql.GenericParameterValueSet.<init>(Unknown > Source) > at org.apache.derby.impl.sql.GenericParameterValueSet.getClone(Unknown > Source) > at org.apache.derby.impl.jdbc.EmbedPreparedStatement.addBatch(Unknown > Source) > at org.hibernate.jdbc.BatchingBatcher.addToBatch(BatchingBatcher.java:31) > at > org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2252) > at > org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2665) > > Also, I need to save it as type 'text' even though it gets saved as > CLOB(255), as the CLOB column size can later be altered. > > What could be the cause? or changes needed? > You have discovered / triggered a bug in the new Clob handling code introduced in 10.5.1. I logged DERBY-4278 [1], and have started working on a fix (the regression tests are running, patch needs review). Regarding workarounds, I'm afraid all I can think of is using the client driver instead of the embedded driver, avoid batching for inserts with Clobs, change the data type, or downgrade to 10.4. Another option is to build Derby with the patch and test it out :) I observe that you are using very small Clobs (255 characters). Clobs are in general less effective than using for instance VARCHAR. Is your concern about altering the column size related to Derby, Hibernate or something else? Regards, -- Kristian [1] https://issues.apache.org/jira/browse/DERBY-4278 > thanks all > > > |
|
|
Re: Hibernate + Derby - Unable to determine stream header for hibernate type 'text'Dear Kristian,
Regarding your remark about effectiveness of very small CLOB vs VARCHAR should I just use VARCHAR to store 100 to 2000 character data instead of CLOB? I do not want to index this column and storage size and access speed (read only) are important. Thanks, Peter 2009/6/19, Kristian Waagan <Kristian.Waagan@...>: > kashyup wrote: >> Hello all, >> We have just started to look into Derby as our embedded DB for a desktop >> app >> version. >> >> Env: Hibernate 3.2 and Derby 10.5.1 >> >> I have defined a java string field of type 'text' in Hibernate Mapping >> (works great on Postgres 8.1 and Oracle 10g) >> >> I use Hibernate SessionFactory to generate Table schema, which is done >> without any error. >> >> But, when I try to save records in tables via Hibernate Session, I get the >> following exception: >> Note: If I change hibernate mapping to type 'string', then I dont get this >> error: >> >> java.lang.IllegalStateException: No context, unable to determine which >> stream header format to generate >> at >> org.apache.derby.iapi.types.ClobStreamHeaderGenerator.determineMode(Unknown >> Source) >> at >> org.apache.derby.iapi.types.ClobStreamHeaderGenerator.expectsCharCount(Unknown >> Source) >> at org.apache.derby.iapi.types.ReaderToUTF8Stream.fillBuffer(Unknown >> Source) >> at org.apache.derby.iapi.types.ReaderToUTF8Stream.read(Unknown Source) >> at java.io.DataInputStream.read(Unknown Source) >> at org.apache.derby.iapi.types.SQLClob.readExternal(Unknown Source) >> at org.apache.derby.iapi.types.SQLChar.getString(Unknown Source) >> at org.apache.derby.iapi.types.SQLClob.getClone(Unknown Source) >> at org.apache.derby.impl.sql.GenericParameter.getClone(Unknown Source) >> at org.apache.derby.impl.sql.GenericParameterValueSet.<init>(Unknown >> Source) >> at org.apache.derby.impl.sql.GenericParameterValueSet.getClone(Unknown >> Source) >> at org.apache.derby.impl.jdbc.EmbedPreparedStatement.addBatch(Unknown >> Source) >> at org.hibernate.jdbc.BatchingBatcher.addToBatch(BatchingBatcher.java:31) >> at >> org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2252) >> at >> org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2665) >> >> Also, I need to save it as type 'text' even though it gets saved as >> CLOB(255), as the CLOB column size can later be altered. >> >> What could be the cause? or changes needed? >> > Hello, > > You have discovered / triggered a bug in the new Clob handling code > introduced in 10.5.1. > I logged DERBY-4278 [1], and have started working on a fix (the > regression tests are running, patch needs review). > > Regarding workarounds, I'm afraid all I can think of is using the client > driver instead of the embedded driver, avoid batching for inserts with > Clobs, change the data type, or downgrade to 10.4. Another option is to > build Derby with the patch and test it out :) > I observe that you are using very small Clobs (255 characters). Clobs > are in general less effective than using for instance VARCHAR. > Is your concern about altering the column size related to Derby, > Hibernate or something else? > > > Regards, > -- > Kristian > > [1] https://issues.apache.org/jira/browse/DERBY-4278 >> thanks all >> >> >> > > |
|
|
Re: Hibernate + Derby - Unable to determine stream header for hibernate type 'text'Hi kristian,
thanks for logging the bug. I will try to look for some workarounds. The CLOB(255) column size limitation is another open bug logged in Hibernate. As Hibernate's DerbyDialect creates a CLOB(255) for java strings mapped as type 'text' in .hbm files. I am using the same set of mapping files on Postgres8.3 and Oracle10g. Type 'text' maps nicely to postgres and Oracle as type 'text' and 'CLOB' resp My idea was to let Hibernate create CLOB(255) columns in Derby, and then I can write an alter column sql to change the CLOB column size. And then run my app on Derby using the same Hibernate mappings. Seems like i will have to work on quite a few workarounds. thanks kashyup
|
|
|
Re: Hibernate + Derby - Unable to determine stream header for hibernate type 'text'Hi Kristian,
Looking at the jira: https://issues.apache.org/jira/browse/DERBY-4278 seems like you have fixed the issue. Previously I downloaded Derby 10.5.1.1 What would be the best way to get this fix? Should I do a check out from the Development Trunk? thanks Kashyup
|
|
|
Re: Hibernate + Derby - Unable to determine stream header for hibernate type 'text'Hi Kashyup,
At the risk of being pedantic, I just wanted to point out that Kristian has posted a candidate fix but he hasn't checked it in yet. It would be great if you could take the fix for a test-drive and let us know if it solves your problem. You will need to do the following: 1) Check out the trunk using subversion. 2) Apply Kristian's fix using the "patch" utility. 3) Build the code. If you need help figuring out how to do this, let us know. Thanks, -Rick kashyup wrote: > Hi Kristian, > Looking at the jira: https://issues.apache.org/jira/browse/DERBY-4278 > https://issues.apache.org/jira/browse/DERBY-4278 > seems like you have fixed the issue. > > Previously I downloaded Derby 10.5.1.1 > > What would be the best way to get this fix? Should I do a check out from the > Development Trunk? > > thanks > > Kashyup > > > > > Kristian Waagan-4 wrote: > >> kashyup wrote: >> >>> Hello all, >>> We have just started to look into Derby as our embedded DB for a desktop >>> app >>> version. >>> >>> Env: Hibernate 3.2 and Derby 10.5.1 >>> >>> I have defined a java string field of type 'text' in Hibernate Mapping >>> (works great on Postgres 8.1 and Oracle 10g) >>> >>> I use Hibernate SessionFactory to generate Table schema, which is done >>> without any error. >>> >>> But, when I try to save records in tables via Hibernate Session, I get >>> the >>> following exception: >>> Note: If I change hibernate mapping to type 'string', then I dont get >>> this >>> error: >>> >>> java.lang.IllegalStateException: No context, unable to determine which >>> stream header format to generate >>> at >>> org.apache.derby.iapi.types.ClobStreamHeaderGenerator.determineMode(Unknown >>> Source) >>> at >>> org.apache.derby.iapi.types.ClobStreamHeaderGenerator.expectsCharCount(Unknown >>> Source) >>> at org.apache.derby.iapi.types.ReaderToUTF8Stream.fillBuffer(Unknown >>> Source) >>> at org.apache.derby.iapi.types.ReaderToUTF8Stream.read(Unknown Source) >>> at java.io.DataInputStream.read(Unknown Source) >>> at org.apache.derby.iapi.types.SQLClob.readExternal(Unknown Source) >>> at org.apache.derby.iapi.types.SQLChar.getString(Unknown Source) >>> at org.apache.derby.iapi.types.SQLClob.getClone(Unknown Source) >>> at org.apache.derby.impl.sql.GenericParameter.getClone(Unknown Source) >>> at org.apache.derby.impl.sql.GenericParameterValueSet.<init>(Unknown >>> Source) >>> at org.apache.derby.impl.sql.GenericParameterValueSet.getClone(Unknown >>> Source) >>> at org.apache.derby.impl.jdbc.EmbedPreparedStatement.addBatch(Unknown >>> Source) >>> at >>> org.hibernate.jdbc.BatchingBatcher.addToBatch(BatchingBatcher.java:31) >>> at >>> org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2252) >>> at >>> org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2665) >>> >>> Also, I need to save it as type 'text' even though it gets saved as >>> CLOB(255), as the CLOB column size can later be altered. >>> >>> What could be the cause? or changes needed? >>> >>> >> Hello, >> >> You have discovered / triggered a bug in the new Clob handling code >> introduced in 10.5.1. >> I logged DERBY-4278 [1], and have started working on a fix (the >> regression tests are running, patch needs review). >> >> Regarding workarounds, I'm afraid all I can think of is using the client >> driver instead of the embedded driver, avoid batching for inserts with >> Clobs, change the data type, or downgrade to 10.4. Another option is to >> build Derby with the patch and test it out :) >> I observe that you are using very small Clobs (255 characters). Clobs >> are in general less effective than using for instance VARCHAR. >> Is your concern about altering the column size related to Derby, >> Hibernate or something else? >> >> >> Regards, >> -- >> Kristian >> >> [1] https://issues.apache.org/jira/browse/DERBY-4278 >> >>> thanks all >>> >>> >>> >>> >> >> > > |
|
|
Re: Hibernate + Derby - Unable to determine stream header for hibernate type 'text'took for a test-drive and runs great!
Thanks Krisitian, Rick for the fast response and fix! kashyup
|
|
|
Re: Hibernate + Derby - Unable to determine stream header for hibernate type 'text'Peter Ondruška wrote:
> Dear Kristian, > > Regarding your remark about effectiveness of very small CLOB vs > VARCHAR should I just use VARCHAR to store 100 to 2000 character data > instead of CLOB? I do not want to index this column and storage size > and access speed (read only) are important. > Hi Peter, It is hard to be sure without knowing the application, but based on what you are saying in your mail I would say you should use VARCHAR instead of CLOB for such small values. In the scenario above you would run through a less complicated code path, and also save three bytes for the header per value. The former should make your accesses somewhat faster. In a different thread I wrote that a single record select test got a (normalized) throughput of 1.00 using VARCHAR and 0.77 using CLOB when the value was 100 characters long. If I get some free cycles, I may run the same test with the maximum length allowed for the VARCHAR data type and see if the difference changes. At least in 10.4, the result would depend on the value itself as well (the bytes per char encoding ratio). Regards, -- Kristian > Thanks, > > Peter > > 2009/6/19, Kristian Waagan <Kristian.Waagan@...>: > >> kashyup wrote: >> >>> Hello all, >>> We have just started to look into Derby as our embedded DB for a desktop >>> app >>> version. >>> >>> Env: Hibernate 3.2 and Derby 10.5.1 >>> >>> I have defined a java string field of type 'text' in Hibernate Mapping >>> (works great on Postgres 8.1 and Oracle 10g) >>> >>> I use Hibernate SessionFactory to generate Table schema, which is done >>> without any error. >>> >>> But, when I try to save records in tables via Hibernate Session, I get the >>> following exception: >>> Note: If I change hibernate mapping to type 'string', then I dont get this >>> error: >>> >>> java.lang.IllegalStateException: No context, unable to determine which >>> stream header format to generate >>> at >>> org.apache.derby.iapi.types.ClobStreamHeaderGenerator.determineMode(Unknown >>> Source) >>> at >>> org.apache.derby.iapi.types.ClobStreamHeaderGenerator.expectsCharCount(Unknown >>> Source) >>> at org.apache.derby.iapi.types.ReaderToUTF8Stream.fillBuffer(Unknown >>> Source) >>> at org.apache.derby.iapi.types.ReaderToUTF8Stream.read(Unknown Source) >>> at java.io.DataInputStream.read(Unknown Source) >>> at org.apache.derby.iapi.types.SQLClob.readExternal(Unknown Source) >>> at org.apache.derby.iapi.types.SQLChar.getString(Unknown Source) >>> at org.apache.derby.iapi.types.SQLClob.getClone(Unknown Source) >>> at org.apache.derby.impl.sql.GenericParameter.getClone(Unknown Source) >>> at org.apache.derby.impl.sql.GenericParameterValueSet.<init>(Unknown >>> Source) >>> at org.apache.derby.impl.sql.GenericParameterValueSet.getClone(Unknown >>> Source) >>> at org.apache.derby.impl.jdbc.EmbedPreparedStatement.addBatch(Unknown >>> Source) >>> at org.hibernate.jdbc.BatchingBatcher.addToBatch(BatchingBatcher.java:31) >>> at >>> org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2252) >>> at >>> org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2665) >>> >>> Also, I need to save it as type 'text' even though it gets saved as >>> CLOB(255), as the CLOB column size can later be altered. >>> >>> What could be the cause? or changes needed? >>> >>> >> Hello, >> >> You have discovered / triggered a bug in the new Clob handling code >> introduced in 10.5.1. >> I logged DERBY-4278 [1], and have started working on a fix (the >> regression tests are running, patch needs review). >> >> Regarding workarounds, I'm afraid all I can think of is using the client >> driver instead of the embedded driver, avoid batching for inserts with >> Clobs, change the data type, or downgrade to 10.4. Another option is to >> build Derby with the patch and test it out :) >> I observe that you are using very small Clobs (255 characters). Clobs >> are in general less effective than using for instance VARCHAR. >> Is your concern about altering the column size related to Derby, >> Hibernate or something else? >> >> >> Regards, >> -- >> Kristian >> >> [1] https://issues.apache.org/jira/browse/DERBY-4278 >> >>> thanks all >>> >>> >>> >>> >> |
|
|
Re: Hibernate + Derby - Unable to determine stream header for hibernate type 'text'kashyup wrote:
> took for a test-drive and runs great! > > Thanks Krisitian, Rick for the fast response and fix! > Thank you for testing the patch, kashyup :) It has now been committed to the development trunk, and will be back-ported to the 10.5 branch in a few days. -- Kristian > kashyup > > > > R [ snip ] |
| Free embeddable forum powered by Nabble | Forum Help |