You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Sudheer <su...@gmail.com> on 2010/02/26 12:09:02 UTC

Custom PK and Pagination

I have created custom type in Java by extending AbstractType and added same
to existing types (SQL Server). This is the primary key. Java type is
CustomUuid and DB type is Binary (16). Also I am performing select
operation. Everything worked fine till I started using pagination. I got
below error when I used pagination

INFO  QueryLogger: SELECT t0.amstat, t0.aorigin, t0.col1, t0.col2, t0.col3,
t0.col4, t0.id, t0.label, t0.lrundate, t0.ptstat, t0.rcstat, t0.sdstat,
t0.state, t0.tlevel, t0.usage_list FROM allcomputers t0 WHERE (t0.id = ?) OR
(t0.id = ?) [bind: [com.xx.cayenne.util.CustomUuid:
b06a638b06cca449bffd7049cc389847], [com.xx.cayenne.util.CustomUuid:
771a7f8b57006744b47d541bd5a796a5]]
INFO  QueryLogger: *** error.
com.microsoft.sqlserver.jdbc.SQLServerException: The Java type
com.ca.cayenne.util.CustomUuid is not a supported type.
        at
com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown
Source)
Exception in thread "main" org.apache.cayenne.CayenneRuntimeException:
[v.2.0.4 October 8 2007] Query exception.
        at
com.microsoft.sqlserver.jdbc.AppDTVImpl$SetValueOp.executeDefault(Unknown
Source)
        at com.microsoft.sqlserver.jdbc.DTV.executeOp(Unknown
Source).............................

Am I missing something here???

Is pagination allowed when Custom type is set as primary key? 

I am using Cayenne 2.0 (latest). Thanks in advance.

-- 
View this message in context: http://n3.nabble.com/Custom-PK-and-Pagination-tp417066p417066.html
Sent from the Cayenne - User mailing list archive at Nabble.com.

Re: Custom PK and Pagination

Posted by Sudheer <su...@gmail.com>.
I think problem is I did not override setJdbcObject() in my custom type.
After doing that it started working. Now I am using 3.0.
-- 
View this message in context: http://n3.nabble.com/Custom-PK-and-Pagination-tp417066p423238.html
Sent from the Cayenne - User mailing list archive at Nabble.com.

Re: Custom PK and Pagination

Posted by Sudheer <su...@gmail.com>.
Thanks Andrus. I will check with 3.0 and update.
-- 
View this message in context: http://n3.nabble.com/Custom-PK-and-Pagination-tp417066p419005.html
Sent from the Cayenne - User mailing list archive at Nabble.com.

Re: Custom PK and Pagination

Posted by Andrus Adamchik <an...@objectstyle.org>.
On Feb 27, 2010, at 6:22 AM, Sudheer wrote:

> Sure I will take look with Cayenne 3.0. Actually I want to take the  
> stable
> relase.

Sure. 3.0 is "stable" in a sense that there's no new development on  
this branch for about 5 months and the API is frozen. Only bug fixes  
are checked in. It will also become "final" soon.

> In 2.0 is there a problem with pagination when custom type is used  
> as PK?

Not a known problem, but possibly you stumbled into something new. If  
3.0 happens to fix it, this will save us some time investigating the  
older release (and you waiting for the fix). If not, this will get our  
immediate attention. So this is where I was coming from with 3.0  
recommendation.

Andrus

Re: Custom PK and Pagination

Posted by Sudheer <su...@gmail.com>.
Thanks for the reply..

Sure I will take look with Cayenne 3.0. Actually I want to take the stable
relase.

With custom type as PK everything worked for except pagination. I have small
demo database and tried with page size 2.

In 2.0 is there a problem with pagination when custom type is used as PK?
-- 
View this message in context: http://n3.nabble.com/Custom-PK-and-Pagination-tp417066p418582.html
Sent from the Cayenne - User mailing list archive at Nabble.com.

Re: Custom PK and Pagination

Posted by Andrus Adamchik <an...@objectstyle.org>.
I would also recommend trying it with Cayenne 3.0, as the pagination  
code in 3.0 was significantly rewritten.

Andrus

On Feb 26, 2010, at 3:35 PM, Michael Gentry wrote:

> I used custom PKs (and a custom PK generator) on a previous project
> that was based upon Cayenne 2.0.  My PKs were 96-bit binary, so I'm
> sure a 16-bit binary would work.  I never tried pagination, though.
>
> Are you sure you are having a problem with pagination?  Your SELECT
> statement only shows 2 IDs, but I suppose your list could be small.
>
> mrg
>
>
> On Fri, Feb 26, 2010 at 6:09 AM, Sudheer <su...@gmail.com>  
> wrote:
>>
>> I have created custom type in Java by extending AbstractType and  
>> added same
>> to existing types (SQL Server). This is the primary key. Java type is
>> CustomUuid and DB type is Binary (16). Also I am performing select
>> operation. Everything worked fine till I started using pagination.  
>> I got
>> below error when I used pagination
>>
>> INFO  QueryLogger: SELECT t0.amstat, t0.aorigin, t0.col1, t0.col2,  
>> t0.col3,
>> t0.col4, t0.id, t0.label, t0.lrundate, t0.ptstat, t0.rcstat,  
>> t0.sdstat,
>> t0.state, t0.tlevel, t0.usage_list FROM allcomputers t0 WHERE  
>> (t0.id = ?) OR
>> (t0.id = ?) [bind: [com.xx.cayenne.util.CustomUuid:
>> b06a638b06cca449bffd7049cc389847], [com.xx.cayenne.util.CustomUuid:
>> 771a7f8b57006744b47d541bd5a796a5]]
>> INFO  QueryLogger: *** error.
>> com.microsoft.sqlserver.jdbc.SQLServerException: The Java type
>> com.ca.cayenne.util.CustomUuid is not a supported type.
>>        at
>> com 
>> .microsoft 
>> .sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown
>> Source)
>> Exception in thread "main"  
>> org.apache.cayenne.CayenneRuntimeException:
>> [v.2.0.4 October 8 2007] Query exception.
>>        at
>> com.microsoft.sqlserver.jdbc.AppDTVImpl 
>> $SetValueOp.executeDefault(Unknown
>> Source)
>>        at com.microsoft.sqlserver.jdbc.DTV.executeOp(Unknown
>> Source).............................
>>
>> Am I missing something here???
>>
>> Is pagination allowed when Custom type is set as primary key?
>>
>> I am using Cayenne 2.0 (latest). Thanks in advance.
>>
>> --
>> View this message in context: http://n3.nabble.com/Custom-PK-and-Pagination-tp417066p417066.html
>> Sent from the Cayenne - User mailing list archive at Nabble.com.
>>
>


Re: Custom PK and Pagination

Posted by Michael Gentry <mg...@masslight.net>.
I used custom PKs (and a custom PK generator) on a previous project
that was based upon Cayenne 2.0.  My PKs were 96-bit binary, so I'm
sure a 16-bit binary would work.  I never tried pagination, though.

Are you sure you are having a problem with pagination?  Your SELECT
statement only shows 2 IDs, but I suppose your list could be small.

mrg


On Fri, Feb 26, 2010 at 6:09 AM, Sudheer <su...@gmail.com> wrote:
>
> I have created custom type in Java by extending AbstractType and added same
> to existing types (SQL Server). This is the primary key. Java type is
> CustomUuid and DB type is Binary (16). Also I am performing select
> operation. Everything worked fine till I started using pagination. I got
> below error when I used pagination
>
> INFO  QueryLogger: SELECT t0.amstat, t0.aorigin, t0.col1, t0.col2, t0.col3,
> t0.col4, t0.id, t0.label, t0.lrundate, t0.ptstat, t0.rcstat, t0.sdstat,
> t0.state, t0.tlevel, t0.usage_list FROM allcomputers t0 WHERE (t0.id = ?) OR
> (t0.id = ?) [bind: [com.xx.cayenne.util.CustomUuid:
> b06a638b06cca449bffd7049cc389847], [com.xx.cayenne.util.CustomUuid:
> 771a7f8b57006744b47d541bd5a796a5]]
> INFO  QueryLogger: *** error.
> com.microsoft.sqlserver.jdbc.SQLServerException: The Java type
> com.ca.cayenne.util.CustomUuid is not a supported type.
>        at
> com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown
> Source)
> Exception in thread "main" org.apache.cayenne.CayenneRuntimeException:
> [v.2.0.4 October 8 2007] Query exception.
>        at
> com.microsoft.sqlserver.jdbc.AppDTVImpl$SetValueOp.executeDefault(Unknown
> Source)
>        at com.microsoft.sqlserver.jdbc.DTV.executeOp(Unknown
> Source).............................
>
> Am I missing something here???
>
> Is pagination allowed when Custom type is set as primary key?
>
> I am using Cayenne 2.0 (latest). Thanks in advance.
>
> --
> View this message in context: http://n3.nabble.com/Custom-PK-and-Pagination-tp417066p417066.html
> Sent from the Cayenne - User mailing list archive at Nabble.com.
>