Re: ejb3 - blob in primary key
- From: Philip Reimer <preimer@xxxxxxxxxxxxxxx>
- Date: Fri, 30 Jun 2006 10:17:42 +0200
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
A.A. schrieb:
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.
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
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.4 (MingW32)
iD8DBQFEpN4mOnXHmEVwvcQRAnGqAJ9/+aCKqGNyKJui+hrTnLE/sD76UQCgi7JH
gpznOrMAQ4cpngULYxa2kjw=
=idSU
-----END PGP SIGNATURE-----
.
- References:
- ejb3 - blob in primary key
- From: Philip Reimer
- Re: ejb3 - blob in primary key
- From: A.A.
- ejb3 - blob in primary key
- Prev by Date: Re: Java MS Excel read write question
- Next by Date: Re: cut and join mp3-files with known bitrate
- Previous by thread: Re: ejb3 - blob in primary key
- Next by thread: Re: ejb3 - blob in primary key
- Index(es):
Relevant Pages
|
|