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)

Key: NUCCORE-718
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Andy Jefferson
Reporter: subes
Votes: 0
Watchers: 0

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

create a QueryHints constants class

Created: 01/Jun/11 07:59 PM   Updated: 14/Jun/11 12:16 PM   Resolved: 03/Jun/11 01:04 PM
Component/s: Queries
Affects Version/s: None
Fix Version/s: 3.0.0.m5

File Attachments: 1. Java Source File (1 kB)

Severity: Development

 Description  « Hide
It would be nice to have a class which provides constants for QueryHints like hibernate does:

This makes development easier, because:
1. brings in type safety when using the constants instead of string literals, thus during datanucleus upgrades immediately detecting changed/removed hints through compiler errors.
2. it is an easy to find reference for available query hints, thus not having to memorize the strings and not needing to look them up in the documentation on the datanucleus website.

Also it might be a good design decision in datanucleus to use string constants for property names instead of string literals all over the code, thus making datanucleus more maintainable and transparent to developers. Having constants for this also eases the navigation during development, because reference searches are possible to look for places where the properties are actually put or read. The current state is kind of an anti-pattern like "magic numbers", though not being as bad with the string literals, but nevertheless a redundancy in code that could be removed. But anyway, this is just a hint for a refactoring. I would be satisfied if there is a QueryHints class with constants. ;)

See attached file for a proposed solution. would then look like this:
public Set<String> getSupportedExtensions()
   return QueryHints.getDefinedHints();

I did not include the hint from the jpa spec "javax.persistence.query.timeout", because I dunno if datanucleus actually supports it.

Sort Order: Ascending order - Click to sort in descending order
subes added a comment - 01/Jun/11 08:00 PM
Proposed constants file.

Andy Jefferson added a comment - 03/Jun/11 01:04 PM
"" has the majority of the constants for *extensions* (prefixed EXTENSION). JDOQLQuery/JPQLQuery have some further constants for extensions. These have to go in multiple places since DataNucleus is not Hibernate, catering for a single datastore.

Providing them as constants is more for internal code structure and to avoid mistyping. We would not recommend people to write code to link to these classes since they would then remove their portability, but at least now they have the choice.