DataNucleus JIRA is now in read-only mode. Raise any new issues in GitHub against the plugin that it applies to. DataNucleus JIRA will remain for the foreseeable future but will eventually be discontinued
Issue Details (XML | Word | Printable)

Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Unassigned
Reporter: Daniel Baldes
Votes: 0
Watchers: 0

If you were logged in you would be able to see more operations.
DataNucleus Store RDBMS

DN does not recognize SQL comments when looking for the ID column

Created: 29/Aug/11 10:31 AM   Updated: 03/Oct/11 07:38 AM   Resolved: 29/Aug/11 08:28 PM
Component/s: None
Affects Version/s: None
Fix Version/s: 3.0.2

File Attachments: 1. Text File sqlcomments.patch (1 kB)

Forum Thread URL:,6830

 Description  « Hide
Comments in SQL queries are not recognized when DataNucleus checks for selection of ID columns in an SQL query with a result class.

This makes it impossible, for example, to add Oracle optimizer hints to a query.

Patch follows.

Sort Order: Ascending order - Click to sort in descending order
Daniel Baldes added a comment - 29/Aug/11 10:33 AM - edited
Attached a patch against the trunk which implements very simple comment-removal before PK column recognition. The regex-based approach should be precise enough here as it is only used during PK column recognition.

Daniel Baldes added a comment - 29/Aug/11 10:40 AM
Another possible approach would be to remove the string-based ID column check, and check for existence of the column(s) in the ResultSet. That would be better, as it would leave the parsing to the database, which needs to do that anyway and accepts all possible syntax.

Andy Jefferson added a comment - 29/Aug/11 07:34 PM
The other possible approach is invalid since compile() has to flag missing columns as per the JDO spec, and the JDO TCK would then fail.
I'll review the patch when time. thx

Andy Jefferson added a comment - 29/Aug/11 08:28 PM
SVN trunk now includes this patch, and also drops checks of resultSet presence of version, discriminator, and id since those are checked in the compile step