This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 211326 - Add default-timeout support to the EclipseLink-ORM.XML Schema
Summary: Add default-timeout support to the EclipseLink-ORM.XML Schema
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: All Windows XP
: P5 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 226515
  Show dependency tree
 
Reported: 2007-11-28 14:51 EST by Guy Pelletier CLA
Modified: 2022-06-09 10:31 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Guy Pelletier CLA 2007-11-28 14:51:59 EST
 
Comment 1 Guy Pelletier CLA 2008-04-08 16:23:46 EDT
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
    )
  }

Comment 2 Guy Pelletier CLA 2008-04-08 16:27:14 EDT
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.
Comment 3 Doug Clarke CLA 2008-04-09 14:39:26 EDT
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?
Comment 4 Guy Pelletier CLA 2008-04-09 14:57:12 EDT
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?
Comment 5 Guy Pelletier CLA 2008-04-09 15:20:43 EDT
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.
Comment 6 Doug Clarke CLA 2008-04-09 16:59:40 EDT
If the current deployment XML schema supports a default timeout then we need a place in the new one to migrate that value to.
Comment 7 Guy Pelletier CLA 2008-04-10 10:59:31 EDT
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.
Comment 8 Guy Pelletier CLA 2008-04-10 15:56:09 EDT
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>
Comment 9 Doug Clarke CLA 2008-04-10 22:21:34 EDT
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.
Comment 10 Doug Clarke CLA 2008-04-10 23:08:55 EDT
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")
Comment 11 Guy Pelletier CLA 2008-04-11 10:27:42 EDT
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?
Comment 12 Guy Pelletier CLA 2008-06-10 15:05:42 EDT
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
Comment 13 Peter Krogh CLA 2009-04-03 16:02:26 EDT
These JPA enhancements were accidentally assigned to 1.1.1.
Comment 14 Doug Clarke CLA 2009-11-27 11:00:17 EST
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
Comment 15 Guy Pelletier CLA 2010-06-01 14:24:52 EDT
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.
Comment 16 Eclipse Webmaster CLA 2022-06-09 10:31:27 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink