cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <and...@objectstyle.org>
Subject Re: Select Query on Table with no Primary Key
Date Thu, 07 Jun 2007 10:29:37 GMT
Tore is right - for Cayenne to handle an object (whether read-only on  
read/write), it needs to know which column or columns uniquely  
identify each row. Now... you can fake a PK in your model, even if  
there's none in the db - just select a really unique combination of  
columns, and mark those columns as the PK in the modeler. I've mapped  
tables with such "imaginary PK" a lot.

If it is not possible (i.e. duplicate rows are expected to be  
fetched), you will have to use DataRows.

Andrus


On Jun 7, 2007, at 1:04 PM, Tore Halset wrote:

> On Jun 6, 2007, at 16:12 , Dave Merrin wrote:
>
>> I'm trying to run a SelectQuery on a table with no primary key.  
>> Unfortunately it's not working. Can anybody help? I have no  
>> control over the database so I can't add in primary keys.
>
> As you know the PK are essential not only to update a row, but to  
> make sure a single row maps to a single DataObject in your context.
>
> Some database engines do have a unique invisible column. If your  
> database does this, then perhaps you could map that column as your  
> primary key? What database engine are you using?
>
> Regards,
>  - Tore.
>


Mime
View raw message