You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by Jeffrey Dawson <je...@guardium.com> on 2006/08/14 21:15:58 UTC

Can a Java object or byte[] be used as a primary key?

I want to use a fixed size byte array as the primary key to a table, but
Torque can't convert between ObjectKey and byte[], and gets compilation
errors in the Base classes.

I was going to try using BigInteger objects as the primary key instead,
but then I get errors during the code generation. The xml for the column
definition looks like this:
  	<column
  		name="DATUM_ID"
 	 	primaryKey="true"
  		required="true"
  		type="JAVA_OBJECT"
  		javaType="object"
  		autoIncrement="false"/>

Am I asking for the impossible?



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Re: Can a Java object or byte[] be used as a primary key?

Posted by Alvaro Coronel <al...@yahoo.com>.
We could go on (using _your_ answer) forever....

But if you really need to know, I was intrigued. I didn't know there were databases that can use binary data (blobs, byte[]) as primary key.

Obviously then, my response was not an answer.

Alvaro.

----- Original Message ----
From: Paul J DeCoursey <pa...@decoursey.net>
To: Apache Torque Users List <to...@db.apache.org>
Sent: Tuesday, August 15, 2006 2:46:53 PM
Subject: Re: Can a Java object or byte[] be used as a primary key?

Alvaro Coronel wrote:
> Wow! What SQL database supports having a byte[] field as primary key?
>
> Regards,
> Álvaro.
>   

How is that a helpful response?

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org






Re: Can a Java object or byte[] be used as a primary key?

Posted by Paul J DeCoursey <pa...@decoursey.net>.
Alvaro Coronel wrote:
> Wow! What SQL database supports having a byte[] field as primary key?
>
> Regards,
> Álvaro.
>   

How is that a helpful response?

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


RE: Can a Java object or byte[] be used as a primary key?

Posted by Declan Shanaghy <to...@shanaghy.com>.
It sounds like your java object is storing application data, is this true?

In a good database design a primary key is of no significance 
to the application other than a means to reference other data.

You may need to reconsider your database design.



-----Original Message-----
From: Alvaro Coronel [mailto:alvarocoronel67@yahoo.com] 
Sent: Tuesday, August 15, 2006 6:26 AM
To: Apache Torque Users List
Subject: Re: Can a Java object or byte[] be used as a primary key?

Wow! What SQL database supports having a byte[] field as primary key?

Regards,
Álvaro.

----- Original Message ----
From: Jeffrey Dawson <je...@guardium.com>
To: torque-user@db.apache.org
Sent: Monday, August 14, 2006 4:15:58 PM
Subject: Can a Java object or byte[] be used as a primary key?

I want to use a fixed size byte array as the primary key to a table, but
Torque can't convert between ObjectKey and byte[], and gets compilation
errors in the Base classes.

I was going to try using BigInteger objects as the primary key instead, but
then I get errors during the code generation. The xml for the column
definition looks like this:
      <column
          name="DATUM_ID"
          primaryKey="true"
          required="true"
          type="JAVA_OBJECT"
          javaType="object"
          autoIncrement="false"/>

Am I asking for the impossible?



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org








---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Re: Can a Java object or byte[] be used as a primary key?

Posted by Alvaro Coronel <al...@yahoo.com>.
Wow! What SQL database supports having a byte[] field as primary key?

Regards,
Álvaro.

----- Original Message ----
From: Jeffrey Dawson <je...@guardium.com>
To: torque-user@db.apache.org
Sent: Monday, August 14, 2006 4:15:58 PM
Subject: Can a Java object or byte[] be used as a primary key?

I want to use a fixed size byte array as the primary key to a table, but
Torque can't convert between ObjectKey and byte[], and gets compilation
errors in the Base classes.

I was going to try using BigInteger objects as the primary key instead,
but then I get errors during the code generation. The xml for the column
definition looks like this:
      <column
          name="DATUM_ID"
          primaryKey="true"
          required="true"
          type="JAVA_OBJECT"
          javaType="object"
          autoIncrement="false"/>

Am I asking for the impossible?



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org