Quantcast

Using bit in primary key not supported?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Using bit in primary key not supported?

Martin Tilsted-2
  In my schema.xml file I have

<table name="templatevalue" idMethod="native">
<column name="name" primaryKey="true" required="true" size="255"
type="VARCHAR"/>
<column default="true" name="preview" primaryKey="true" required="true"
type="BIT"/>
<!-- Other fields removed -->
</table>

But it seems like torque is unable to handle a primary key with a bit
field, because it generate the file

BaseTemplatevalue.java

with the function public ObjectKey getPrimaryKey()
which contain the line

pks[1] = SimpleKey.keyFor(getPreview());

But eclipse complains that there is no SimpleKey.keyFor which take a
boolean argument. So am I doing something wrong, or is this just not
supported.

This is using torque 3.3 with postgresql 8.4.

It's easy to work-around using an int, but I would like to keep it
boolean, because it is a boolean :}

Martin




---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: Using bit in primary key not supported?

Thomas Fischer-11
>   In my schema.xml file I have
>
> <table name="templatevalue" idMethod="native">
> <column name="name" primaryKey="true" required="true" size="255"
> type="VARCHAR"/>
> <column default="true" name="preview" primaryKey="true" required="true"
> type="BIT"/>
> <!-- Other fields removed -->
> </table>

Torque can not generate composite keys automatically, so the idMethod
attribute in the table should be set to "none". Can you change this and try
again ?

   Thomas


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Using bit in primary key not supported?

Martin Tilsted-2
  You are right torque can't generate composite keys. Don't know what I
was thinking. I have changed it to none now. But it seems torque does
know that it can't generate composite keys becasue it generate exactly
the same file with idMethod=native as it does when idMethod=none. Only
difference between the generated files were the value of
serialVersionUID. (Or rather I think that the case is that Torque don't
try to generate a key when idMethod is native).

But the problem remain. But note that the problem is with the
getPrimaryKey() method which if I remember correct is used to get the
key for an existing object, not generate a key for a new object.

Martin


On 10/08/2010 09:23 AM, Thomas Fischer wrote:

>>    In my schema.xml file I have
>>
>> <table name="templatevalue" idMethod="native">
>> <column name="name" primaryKey="true" required="true" size="255"
>> type="VARCHAR"/>
>> <column default="true" name="preview" primaryKey="true" required="true"
>> type="BIT"/>
>> <!-- Other fields removed -->
>> </table>
> Torque can not generate composite keys automatically, so the idMethod
> attribute in the table should be set to "none". Can you change this and try
> again ?
>
>     Thomas
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Using bit in primary key not supported?

Thomas Fox-2
In Torque 3.3 it does not work, sorry. I created a jira issue
https://issues.apache.org/jira/browse/TORQUE-151

However I created a fix for Torque 4.0, see commits at the jira issue. If
you want you can try to backport the fix to 3.3. You need to fix the
runtime and the templates.

    Thomas

>   You are right torque can't generate composite keys. Don't know what I
> was thinking. I have changed it to none now. But it seems torque does
> know that it can't generate composite keys becasue it generate exactly
> the same file with idMethod=native as it does when idMethod=none. Only
> difference between the generated files were the value of
> serialVersionUID. (Or rather I think that the case is that Torque don't
> try to generate a key when idMethod is native).
>
> But the problem remain. But note that the problem is with the
> getPrimaryKey() method which if I remember correct is used to get the
> key for an existing object, not generate a key for a new object.
>
> Martin
>
>
> On 10/08/2010 09:23 AM, Thomas Fischer wrote:
> >>    In my schema.xml file I have
> >>
> >> <table name="templatevalue" idMethod="native">
> >> <column name="name" primaryKey="true" required="true" size="255"
> >> type="VARCHAR"/>
> >> <column default="true" name="preview" primaryKey="true"
required="true"
> >> type="BIT"/>
> >> <!-- Other fields removed -->
> >> </table>
> > Torque can not generate composite keys automatically, so the idMethod
> > attribute in the table should be set to "none". Can you change this and
try

> > again ?
> >
> >     Thomas
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Loading...