Defining a Primary Key as BLOB type

Discussions

EJB programming & troubleshooting: Defining a Primary Key as BLOB type

  1. Defining a Primary Key as BLOB type (2 messages)

    Is it possible to define a Primary Key as BLOB?


    I've defined a table in MySql with the following syntax:

    CREATE TABLE producer (
           producerKey BLOB NOT NULL
         , data BLOB
         , PRIMARY KEY (producerKey(255))
    );

    where producerKey and data are meant for storage of Java Objects, but once I insert one row every other insert command throws a SQLException saying that the field producerKey cannot have the same value. But I'm pretty sure that I'm using different Java Objects in the various insert commands.
    Can anyone give me a hint on how to define a Java Object as a Primary Key?


    Thanks in advance!
  2. Hi,

    It is not a good idea of going with BLOB as a primary key.
    BLOBs can't be indexed so it is not advisable to have BLOB as aprimary key
  3. Thanks for your advice!
    I'll just have to figure out something else then...