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
Operations

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 QueryHints.java (1 kB)


Severity: Development


 Description  « Hide
It would be nice to have a class which provides constants for QueryHints like hibernate does:
http://docs.jboss.org/hibernate/core/3.5/api/org/hibernate/ejb/QueryHints.html

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. org.datanucleus.store.query.Query.getSupportedExtensions() 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.

subes added a comment - 01/Jun/11 08:00 PM
Proposed constants file.

subes made changes - 01/Jun/11 08:00 PM
Field Original Value New Value
Attachment QueryHints.java [ 11450 ]
Andy Jefferson made changes - 03/Jun/11 12:59 PM
Project DataNucleus API JPA [ 10171 ] DataNucleus Core [ 10143 ]
Key NUCJPA-133 NUCCORE-718
Affects Version/s 3.0.0.m4 [ 11227 ]
Component/s Queries [ 10154 ]
Component/s Queries [ 10180 ]
Andy Jefferson added a comment - 03/Jun/11 01:04 PM
"org.datanucleus.store.query.Query" has the majority of the constants for *extensions* (prefixed EXTENSION). org.datanucleus.store.rdbms.query. 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.

Andy Jefferson made changes - 03/Jun/11 01:04 PM
Status Open [ 1 ] Resolved [ 5 ]
Assignee Andy Jefferson [ andy ]
Fix Version/s 3.0.0.m5 [ 11242 ]
Resolution Fixed [ 1 ]
Andy Jefferson made changes - 14/Jun/11 12:16 PM
Status Resolved [ 5 ] Closed [ 6 ]