Discussion:
derby & hibernate & type 'text'
Andy Rozman
2008-04-14 23:40:15 UTC
Permalink
Hi !

I am new to derby and I have one question. I am using Hibernate with my
application and I am having little problems with Derby... (I used same
db configutaion on PostgreSQL, Mckoi and HsqlDb)...

It seems that type text (which should be unlimited varchar) is
interpreted as CLOB(255). I don't know where this happens but my
application now fails... Is this Derby problem or Hibernate? I am using
latest of Derby (10.3.2.1) and Hibernate 3.1.

Which is longest varchar format in Derby?

If someone uses Hibernate with Derby I would be thankful for any help...

Andy
Mamta Satoor
2008-04-15 06:18:51 UTC
Permalink
Hi Andy,

I am not sure what you mean by your application fails but here is some
general information about CLOB datatype in Derby. In Derby, CLOB
values are limited to a maximum of 2,147,483,647 characters. Derby
documentation on various datatypes can be found in Reference Manual at
http://db.apache.org/derby/manuals/index.html#docs_10.3

Mamta
Post by Andy Rozman
Hi !
I am new to derby and I have one question. I am using Hibernate with my
application and I am having little problems with Derby... (I used same db
configutaion on PostgreSQL, Mckoi and HsqlDb)...
It seems that type text (which should be unlimited varchar) is interpreted
as CLOB(255). I don't know where this happens but my application now
fails... Is this Derby problem or Hibernate? I am using latest of Derby
(10.3.2.1) and Hibernate 3.1.
Which is longest varchar format in Derby?
If someone uses Hibernate with Derby I would be thankful for any help...
Andy
Damian Carey
2008-04-15 06:40:48 UTC
Permalink
Post by Andy Rozman
Hi !
I am new to derby and I have one question. I am using Hibernate with my
application and I am having little problems with Derby... (I used same db
configutaion on PostgreSQL, Mckoi and HsqlDb)...
It seems that type text (which should be unlimited varchar) is interpreted
as CLOB(255). I don't know where this happens but my application now
fails... Is this Derby problem or Hibernate? I am using latest of Derby
(10.3.2.1) and Hibernate 3.1.
Which is longest varchar format in Derby?
If someone uses Hibernate with Derby I would be thankful for any help...
Andy
We use both Derby and Postgres with Hibernate, so here are a few
ideas. I guess your hibernate mapping is something like ...
<property name="nbString" type="text">
<column name="nbString"/>
</property>

CLOB(255) is likely being set by the hibernate "Dialect". (Db2Dialect
I think ??) The Postgres dialect can have the "text" type, which does
have a limit of around a gig. However Derby is different. The longest
varchar in derby is 32672 long. In hibernate you set it thus ...
<property name="nbString" type="string">
<column name="nbString" length="32672"/>
</property>

Typically you are better off with the string in preference to the CLOB
because you can do more sophisticated text searches in a string than
in a clob. Of course it depends on what you are doing.

HTH
Cheers,
-Damian
Thomas Nielsen
2008-04-15 06:45:59 UTC
Permalink
Post by Andy Rozman
It seems that type text (which should be unlimited varchar) is
interpreted as CLOB(255). I don't know where this happens but my
application now fails... Is this Derby problem or Hibernate? I am using
latest of Derby (10.3.2.1) and Hibernate 3.1.
Hi Andy,

Hibernate seems to map its 'text' type to a database clob, not a
database varchar. This is Hibernates doing, not Derbys. See attached
link to Hibernate "cheat sheet"[1].

You might be better off with using Hibernates 'string' type which maps
to a database varchar type?

I'm not sure exactly why it fails using 'text' and a clob with derby,
but I do know there are a few clob related fixes in the upcoming 10.4
release.

The release candidate of Derby 10.4 is now available[2], and the
official release should be just around the corner. Maybe you could give
the RC a quick spin to see if the problem is solved?

Cheers,
Thomas

[1] http://ndpsoftware.com/HibernateMappingCheatSheet.html
[2] http://wiki.apache.org/db-derby/DerbyTenFourRelease -->
ReleaseCandidates
--
Thomas Nielsen
Loading...