[ 
https://issues.apache.org/jira/browse/CAY-1986?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14600011#comment-14600011
 ] 

John Huss commented on CAY-1986:
--------------------------------

So there are two reasonable options I believe.

1) Throw an exception if an SQLTemplate is supposed to return DataObjects and 
any of the db attributes are missing from the ResultSet.  This catches the 
problem in development with a clear error message.  The current behavior of 
allowing partial snapshots to be returned and then inflated into full objects 
by running another query is really bad for performance since each object is 
then fetched one at a time.  An exception would be much preferable (but is a 
breaking change). 

OR

2) Modify ObjectResolver to make the matching of DbAttributes and ResultSet 
columns case INSENSITIVE.  I don't know if this would be configurable or just 
always on.  This ignores an existing problem with in-memory evaluations of 
DbPaths potentially failing due to case mismatches (that would succeed if done 
in the DB), but that is probably not a frequent problem.  If we do it this way, 
throwing an exception on partial snapshots is still a good idea.


> SQLTemplate returning DataObjects fails on PK column case mismatch
> ------------------------------------------------------------------
>
>                 Key: CAY-1986
>                 URL: https://issues.apache.org/jira/browse/CAY-1986
>             Project: Cayenne
>          Issue Type: Bug
>          Components: Core Library
>    Affects Versions: 4.0.M2
>         Environment: trunk
>            Reporter: John Huss
>            Priority: Minor
>
> If you create an SQLTemplate query that returns real DataObjects (say Artist 
> objects) and use a query like "select * from Artist limit 1" and have the 
> primary key column defined in the DataMap with mixed case (like artist_ID) 
> that doesn't match what the database returns for the column name, the result 
> will contain nulls instead of objects.
> Strangely the case of the other columns does not seem to matter, only the 
> primary key column.
> You can workaround it by naming the column all upper or lower case and 
> configuring the SQLTemplate to force upper or lower case column names to be 
> returned.  But I think it should just work without needing to do this.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to