Community
Participate
Working Groups
To allow users to configure their query timeouts, we'll offer them a couple ways to accomplish this. We'll add the following XML element: <xsd:element name="query-timeout" type="xsd:integer"/> at the following levels of the EclipseLink ORM.XML schema 1 - persistence-unit-defaults: applies to all named queries, named native queries and named stored procedure queries in the persistence unit 2 - entity-mappings: applies (and overrides any persistence-unit-defaults setting) to all named queries, named native queries and named stored procedure queries within that mapping file. 3 - query level (named-query, named-native-query, named-stored-procedure-query): applies (and overrides any entity-mappings or persistence-unit-defaults setting) directly to the query. For the individual queries we'll add the fowlloing element: <xsd:element name="timeout" type="xsd:integer"/> Since we own the NamedStoredProcedureQuery annotation we can add a new member variable to it: /** * (Optional) The timeout value that should apply to the query execution. * A 0 specification would indicate a no timeout policy. */ int timeout() default -1; The problem now lies with configuring the timeout values for existing JPA @NamedQuery and @NamedNativeQuery. We could introduce a @QueryTimeout(s) annotation which would allow users to configure the time out value for their annotations. It would look something like this: Single query case: @NamedQuery( name="query1", query=" .... " ) @QueryTimeout( name="query1", timeout=100 ) Multiple query case: @NamedQueries({ @NamedQuery( name="query1", query=" .... " ), @NamedQuery( name="query2", query=" .... " ) } @NamedNativeQueries({ @NamedNativeQuery( name="query3", query=" .... " ), @NamedNativeQuery( name="query4", query=" .... " ) } @QueryTimeouts{{ @QueryTimeout( name="query1", timeout=0 ), @QueryTimeout( name="query2", timeout=-1 ), @QueryTimeout( name="query3", timeout=100 ), @QueryTimeout( name="query4", timeout=1000 ) }
Note that the existing query XML/Annotation rules would still apply. That is, the user could not specify query1 in XML (and omit setting the timeout value) and pick one up from a @QueryTimeout annotation.
We currently have a hint: eclipselink.jdbc.timeout This value can be specified within the existing JPA annotation and XML. Do we really need to have a separate annotation and XML definition separate for the same value?
Ah, I wasn't aware of this hint. That could make things easier. Yes we could forego the new annotation then and element within queries and avoid that confusion. How about keeping the persistence unit default though and have it apply to all queries across the PU? And keep the entity-mappings level one as well that would override the pu-default one and apply to only those queries within that mapping file? Or scrap it all together?
The more I think about it now, I think in the context of what we are trying to achieve for BUG 200040, this bug should be closed since we already have a means of configuring a timeout value for all queries. Allowing the timeout value to be specified within the persistence-unit-defaults would make sense only if we allowed all our query hint defaults to be configured there. Again, that is something this is outside the scope of this project, so I vote for simply closing this bug.
If the current deployment XML schema supports a default timeout then we need a place in the new one to migrate that value to.
So there is the query-policy configurations from the deployment XML that allows the specification of a default-timeout (among other things) per descriptor. I've entered a new root bug 226515 that covers off the features of the query-policy support and is blocked by bugs for all its sub-parts.
Changes to query policy include the default timeout value. --------------------------------------------------------------- @Target({TYPE}) @Retention(RUNTIME) public @interface QueryPolicy { /** * (Optional) The default timeout value for queries */ int timeout() default -1; ..... } --------------------------------------------------------------- <xsd:complexType name="query-policy"> <xsd:annotation> <xsd:documentation> @Target({TYPE}) @Retention(RUNTIME) public @interface QueryPolicy { /** * (Optional) The default timeout value for queries. * To specify no timeout set the value to 0. */ int timeout() default -1; ..... } </xsd:documentation> </xsd:annotation> <xsd:sequence> ..... </xsd:sequence> <xsd:attribute name="timeout" type="xsd:integer"/> ..... </xsd:complexType>
I struggle with adding an annotation and XML for this. What is the complete set of items in this area of the previous XML schema.
The query-policy section of the existing XSD defines: - list of queries (This is handled by named queries) - timeout - existence-checking - override queries for update, delete, insert, does-exist, read, read-all since the queries section of query-policy is handled by named query support we just need to handle the other 3 items. EXISTENCE-CHECKING: needs to be handled in a separate bug but I believe this should be its own configuration item on the entity using @ExistenceChecking(cache | database | assume-exists | assume-new) with a matching <existence-checking> element in the XSD Assuming those two are dealt with separately we are left with the descriptor level query timeout default value. @QueryDefaults(timeout=100, insert="Foo.insert", delete="Foo.delete")
Existence checking is its own bug 226517 I originally provided a suggestion that would include it witin the query-policy default but will modify it according to your suggestion and provide a separate annotation for it. Seems odd though that we would provide two annotations to configrue the query-policy though since it is a query default and applied to the does-exist query. I thought we were trying to reduce the number of new annotations we create?
Since this is a sub bug of 226515 and the last comment posted for that bug read: "The challenge here is that in JPA queries are define globally for the persistence unit and these are per entity query options. These are rarely used features and we could defer this and it dependent bugs until after 1.0." This bug should be targeted for 1.1
These JPA enhancements were accidentally assigned to 1.1.1.
Moving to 2.1 where our goal is to have the eclipselink-orm.xsd fully support all native features currently available in the deployment XML XSD
Updating priority due to revised bug categorization process. See the following page for details: http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines#Priority_and_Target_Milestone If you feel the updated priority is incorrect, please send an email to eclipselink-users@eclipse.org.
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink