Re: ejb3 - blob in primary key



Philip Reimer wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello all.

I'm trying to deploy a little ejb3 example application on JBoss 4.0.4 in
combination with MySql 5.0.22. In one of the entities I have a primary
key consisting of two fields, the first one is an Integer, the second
one is an Object. I've defined a key class for this compound primary key
and when I change the type of the second primary key field to String,
everything works fine, but when I leave it as an Object the creation of
the according table fails with the error message:

"BLOB/TEXT column 'windowId' used in key specification without a key length"

I found some hints on the internet that mysql requires the user to
define some kind of length for a blob that's used as a primary key, but
I'm not sure how to specify this in my source code. Didn't find any
annotation that seemed fitting. Maybe that's not even possible because
the problem lies within the object-relational mapping functionality.

Furthermore, when using the built-in hypersonic database, the
application deploys just fine in both cases (String and Object).

So, if anyone could point me in the right direction on how to solve this...
Thanks,
Philip

PS: I, of course, tried google and the jboss forums before posting here,
but to no success. Seems as if there are not many people using blobs
with ejbs, and even less using them as primary keys. Maybe it was a bad
idea in the first place?

A Blob as primary key?
This means that the DB engine has to index the Blob.
Have a look at http://dev.mysql.com/doc/refman/5.0/en/indexes.html

Personally, instead of indexing/PKing the Blob, I would generate a hash(MD5 or whatever) from the Blob content and use it in my compound PK.

Arcadius.
.



Relevant Pages

  • ejb3 - blob in primary key
    ... and when I change the type of the second primary key field to String, ... I found some hints on the internet that mysql requires the user to ... define some kind of length for a blob that's used as a primary key, ... I, of course, tried google and the jboss forums before posting here, ...
    (comp.lang.java.programmer)
  • Re: ejb3 - blob in primary key
    ... and when I change the type of the second primary key field to String, ... I found some hints on the internet that mysql requires the user to ... I, of course, tried google and the jboss forums before posting here, ... A Blob as primary key? ...
    (comp.lang.java.programmer)
  • Re: ejb3 - blob in primary key
    ... and when I change the type of the second primary key field to String, ... I found some hints on the internet that mysql requires the user to ... I, of course, tried google and the jboss forums before posting here, ... A Blob as primary key? ...
    (comp.lang.java.programmer)
  • Re: BLOB as primary key
    ... you can't create a Primary Key on a column with datatype image. ... create a Primary Key on a BLOB, it might actually only create a Primary Key ... SQL Server MVP ...
    (microsoft.public.sqlserver.odbc)
  • Re: OracleDataAdapter Update() not working
    ... ImportRow) by using a LoadDataRow, but now, i have a new issue. ... varchar, stuff blob, some number, large varchar, constraint ... PK_Temp primary key )"); ...
    (microsoft.public.dotnet.framework.adonet)