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.A. - 29 Jun 2006 19:32 GMT
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
[quoted text clipped - 28 lines]
> 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.
Philip Reimer - 30 Jun 2006 09:17 GMT
A.A. schrieb:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
[quoted text clipped - 39 lines]
>
> Arcadius.
Hi.
Yes, I've already found that page. But how do I tell JBoss to add the
index when deploying and creating the tables? That really was my question.
But I think, I'll rather change the type back to String or so.
Thanks anyway,
Philip
steve - 30 Jun 2006 11:35 GMT
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
[quoted text clipped - 37 lines]
>
> Arcadius.
personally I would not even do that.
I would add a primary key col and generate a random+the current milisec
time.
that also allows you to recover the date/time for free as well
steve