Search Images Maps Play YouTube News Gmail Drive More »
Sign in
Screen reader users: click this link for accessible mode. Accessible mode has the same essential features but works better with your reader.

Patents

  1. Advanced Patent Search
Publication numberUS20030163460 A1
Publication typeApplication
Application numberUS 10/341,107
Publication dateAug 28, 2003
Filing dateJan 13, 2003
Priority dateJan 18, 2002
Also published asUS7454438, US7587417, US20060173832, US20060173835, WO2003062987A1
Publication number10341107, 341107, US 2003/0163460 A1, US 2003/163460 A1, US 20030163460 A1, US 20030163460A1, US 2003163460 A1, US 2003163460A1, US-A1-20030163460, US-A1-2003163460, US2003/0163460A1, US2003/163460A1, US20030163460 A1, US20030163460A1, US2003163460 A1, US2003163460A1
InventorsMatthew Shinn, Seth White, Rob Woollen
Original AssigneeMatthew Shinn, Seth White, Rob Woollen
Export CitationBiBTeX, EndNote, RefMan
External Links: USPTO, USPTO Assignment, Espacenet
Systems and methods for dynamic querying
US 20030163460 A1
Abstract
A user can generate queries dynamically at runtime without having to redeploy the appropriate EJB or hard-code the query into the user application. A properties object can be generated to accept the query settings from the user. These settings can be extracted at runtime when the appropriate finder method is invoked, such that the desired query statement, such as a SQL statement, can be generated and executed against the database.
This description is not intended to be a complete description of, or limit the scope of, the invention. Other features, aspects, and objects of the invention can be obtained from a review of the specification, the figures, and the claims.
Images(3)
Previous page
Next page
Claims(16)
What is claimed is:
1. A system for dynamically generating a query to be executed on a database, comprising:
a properties object adapted to contain settings for a query as specified by a user;
a finder method for initiating the query; and
a server capable of querying the database, the server capable of receiving a call from the finder method and reading the settings from the properties object in order to generate the appropriate SQL query statements to be sent to the database.
2. A system according to claim 1, further comprising:
a user interface adapted to allow a user to specify the settings in the property object.
3. A system according to claim 1, further comprising:
a client containing the properties object and the finder method.
4. A system according to claim 1, further comprising:
a bean associated with the database upon which the finder method can be invoked.
5. A system according to claim 1, further comprising:
an element in a deployment descriptor for enabling dynamic querying.
6. A method for dynamically generating a query to be executed against a database, comprising:
generating a properties object containing settings for a query;
invoking a finder method;
extracting the settings from the properties object and parsing the finder method in order to generate a query statement; and
executing the query statement on the database.
7. A method according to claim 6, wherein:
generating a properties object occurs at runtime.
8. A method according to claim 6, wherein:
extracting the settings from the properties object and parsing the finder method in order to generate a SQL query statement occurs at runtime.
9. A method according to claim 6, further comprising:
enabling dynamic querying by setting an element in a deployment descriptor.
10. A method according to claim 6, further comprising:
allowing the user to specify the settings for the query at runtime.
11. A method for generating dynamic queries, comprising:
specifying settings to be used in generating the query using a user interface;
generating a properties object to hold the settings;
invoking a finder method; and
parsing the finder method and reading the settings from the property object in order to generate the query.
12. A system for generating dynamic queries, comprising:
means for generating a properties object to hold settings to be used in generating a query;
means for invoking a finder method; and
means for parsing the finder method and reading the settings from the property object in order to generate the query.
13. A computer-readable medium, comprising:
means for generating a properties object to hold settings to be used in generating a query;
means for invoking a finder method; and
means for parsing the finder method and reading the settings from the property object in order to generate the query.
14. A computer program product for execution by a server computer for generating dynamic queries, comprising:
computer code for generating a properties object to hold settings to be used in generating a query;
computer code for invoking a finder method; and
computer code for parsing the finder method and reading the settings from the property object in order to generate the query.
15. A computer system comprising:
a processor;
object code executed by said processor, said object code configured to:
generate a properties object to hold settings to be used in generating a query;
invoke a finder method; and
parse the finder method and reading the settings from the property object in order to generate the query.
16. A computer data signal embodied in a transmission medium, comprising:
a code segment including instructions to generate a properties object to hold settings to be used in generating a query;
a code segment including instructions to invoke a finder method; and
a code segment including instructions to parse the finder method and reading the settings from the property object in order to generate the query.
Description
    CLAIM OF PRIORITY
  • [0001]
    This application claims priority to U.S. Provisional Patent Application No. 60/349,432, filed Jan. 18, 2002, entitled “SYSTEMS AND METHODS FOR DYNAMIC QUERYING,” which is hereby incorporated herein by reference.
  • COPYRIGHT NOTICE
  • [0002]
    A portion of the disclosure of this patent document contains material which is subject to copyright protection. The copyright owner has no objection to the facsimile reproduction by anyone of the patent document of the patent disclosure, as it appears in the Patent and Trademark Office patent file or records, but otherwise reserves all copyright rights whatsoever.
  • FIELD OF THE INVENTION
  • [0003]
    The present invention relates to executing queries against a database.
  • BACKGROUND
  • [0004]
    The Enterprise JavaBean (EJB) specification, published by Sun Microsystems, Inc. of Palo Alto, Calif., describes ways in which a user can execute queries against a database, as well as ways in which a user can communicate queries to an EJB container. Presently, the EJB 2.0 specification forces users to hard-code finder queries into a deployment descriptor for an EJB. A user develops a query before deploying the EJB. Once the EJB is deployed, the user is able to execute the query. A problem exists with this approach, however, in that it is necessary to redeploy the EJB every time the user wishes to run a new query.
  • BRIEF SUMMARY
  • [0005]
    Systems and methods in accordance with one embodiment of the present invention can allow a user to dynamically generate a query to be executed against a database. A properties object can be generated that holds settings for the query, which can be specified by a user at runtime. When the query is to be executed, the user or application can invoke an appropriate finder method. The server receiving the call from the finder method can extract the user-specified settings from the properties object and parse the finder method in order to generate a query statement. The server can then execute the query statement on the database and return the appropriate results. The generating of the properties object and the query statement can happen at runtime.
  • [0006]
    Other features, aspects, and objects of the invention can be obtained from a review of the specification, the figures, and the claims.
  • BRIEF DESCRIPTION OF THE DRAWINGS
  • [0007]
    [0007]FIG. 1 is a diagram of a system in accordance with one embodiment of the present invention.
  • [0008]
    [0008]FIG. 2 is a flowchart showing the steps of a method that can be used with the system of FIG. 1.
  • DETAILED DESCRIPTION
  • [0009]
    Systems and methods in accordance with one embodiment of the present invention can allow a user to define a query programmatically rather than defining the query statically. Static queries are defined, for example, by hard-coding the static query into the deployment descriptor for an EJB. Programmatic queries, or “dynamic queries”, allow users to construct and execute queries in their application code. This can provide several benefits over static queries which utilize static finder methods.
  • [0010]
    One such benefit is the ability to create and execute new queries without having to update and redeploy an EJB. When deploying an EJB with static queries, each query is read and parsed in order to generate the SQL to be sent to the database. Finder methods can be utilized in executing the query, which can be defined in the home interface of an entity bean. An example of a finder method is findByPrimaryKey( ), which can accept an instance of a primary key and return an instance of that entity type (or throw an exception). Additional finder methods can be defined in local home or remote home interfaces, with each finder method being associated with a query in the deployment descriptor. With dynamic queries, however, the query and corresponding SQL can be generated at runtime.
  • [0011]
    Another benefit is that the size of an EJB deployment descriptor is reduced. Since the finder queries can be created dynamically, they do not have to be statically defined in the deployment descriptor. For some applications this approach may be a little slower, but the added flexibility will outweigh the slight hit in performance for many users.
  • [0012]
    One system and method for implementing dynamic queries utilizes the generation of a class such as an ejbHome class. Such a class can be used to implement an extra interface with a method that can execute the query. As shown in FIG. 1, when a user 100 wants to execute a query against a database 112 at runtime, an object such as a Java properties object 104 can be generated that can be populated with the settings for the finder method 106, such as a container-managed or bean-managed finder method. The finder method 106 can then be invoked on the query home of the appropriate EJB 108, which can be stored on a server 110 or EJB container in communication with, and capable of executing SQL queries against, a database 112. Once the call makes it into the server 110, the properties object 104 can be inspected and the user settings extracted. The finder method 106 can be parsed and the SQL query statement generated that is to be sent to the database 112. The query is executed and, depending on the user settings, the use of the results can be determined. One possible result of such a query is a collection of EJBs. Another possible result is a number of values or fields on certain EJBs that match the query.
  • [0013]
    A method that can be used in accordance with the system of FIG. 1 is shown in the flowchart of FIG. 2. In the method, a properties object is generated that contains user-specified settings for the query or the finder method, as can be implemented through a user interface of an ejbHome class 200. The appropriate finder method is invoked when the user or application wishes to execute the query 202. The settings are extracted from the properties object and the finder method is parsed in order to generate the appropriate SQL query statement, although other database or data source querying language statements may be generated by the method 204. The SQL query statement is then executed against the database 206.
  • [0014]
    One embodiment can be implemented through a simple API. To enable the use of dynamic queries, users can add an element to their deployment descriptor, such as:
  • [0015]
    <!ELEMENT enable-dynamic-queries (#PCDATA)>
  • [0016]
    The enable-dynamic-queries element can be a sub-element of a descriptor such as entity-descriptor. The value of enable-dynamic-queries can be either “true” or “false” in this embodiment. Invoking a dynamic query when dynamic queries have not been enabled can result in an exception being thrown, such as java.rmi. AccessException or javax.ejb.AccessLocalException, depending on whether it was invoked from a Remote or Local interface.
  • [0017]
    A generated implementation class, such as HomeImpl that can be used for all EJB 2.0 Container-Managed Persistence (CMP) beans, can implement a new interface such as QueryHome. A QueryHome interface can declare a single method, such as:
    public Object executeQuery(String query, Properties props) throws
    FinderException, RemoteException;
  • [0018]
    There can also be a local version of QueryHome which may be referred to as QueryLocalHome. The only difference between the interfaces can be the “throws” clause of the executeQuery method. The QueryLocalHome iinterface can declare a single method:
    public Object executeQuery(String query, Properties props) throws
    FinderException, EJBException;
  • [0019]
    The application code can make use of this interface as follows:
    InitialContext ic = new InitialContext();
    FooHome fh = (FooHome)ic.lookup(“fooHome”)’
    QueryHome qh = (QueryHome)fh;
    String query = “SELECT OBJECT(e) FROM EmployeeBean e WHERE
    e.name = ‘rob’ ”;
    Properties props = new Properties();
    props.setProperty(DynamicQuery.MAX_ELEMENTS, “10”);
    Collection results = (Collection)qh.executeQuery(query, props);
  • [0020]
    All options that can currently be specified for a static finder can be set in a Properties object passed to the executeQuery method. The Properties key for all valid options can be defined in a DynamicQuery interface. A list of some valid entries is as follows:
    Property: Value: Description:
    GROUP_NAME String The name of the field-group whose
    fields are to be loaded into the cache
    upon execution of the query. Note
    that in order for this to work, a finders-
    load-bean or equivalent option may
    need to be enabled for the EJB.
    MAX_ELEMENTS int The max-elements attribute is used to
    specify the maximum number of
    elements that should be returned by a
    multi-valued query. This option can
    be similar to the maxRows feature of
    JDBC.
    INCLUDE_UPDATES boolean The include-updates tag is used to
    specify that updates made during the
    current transaction must be reflected
    in the result of a query.
    SQL_SELECT_DISTINCT boolean Used to control whether the generated
    SQL ‘SELECT’ will contain a
    ‘DISTINCT’ qualifier. Use of the
    DISTINCT qualifier will cause the
    RDBMS to return unique rows.
    RETURN_TYPE String Indicates the return type of the
    executeQuery method. Legal values
    include Collection,
    CursoredCollection, and ResultSet.
    The default value is
    java.util.Collection.
    NEW_TRANSACTION boolean Indicates whether a new transaction
    should be started for the execution of
    the DynamicQuery
    ISOLATION_LEVEL String Indicates the isolation level to be used
    if a new transaction is started
    RESULT_TYPE_MAPPING String Indicates whether EJBObjects or
    EJBLocalObjects should be returned.
    The legal values are Local and
    Remote. If the query was executed on
    QueryHome, EJBObjects will always
    be returned. If the query was
    executed on QueryLocalHome,
    EJBLocalObjects will be returned by
    default. A result-type-mapping of
    Remote can be specified in this case if
    EJBObjects are desired.
  • [0021]
    Ideally, dynamic queries execute nearly as fast as static queries. Dynamic queries can invariably be somewhat slower since the queries can require parsing at runtime, whereas static queries are parsed during deployment. The speed of dynamic queries can be increased, such as by extending them to take query parameters and caching the parsed query String.
  • [0022]
    The foregoing description of preferred embodiments of the present invention has been provided for the purposes of illustration and description. It is not intended to be exhaustive or to limit the invention to the precise forms disclosed. Many modifications and variations will be apparent to one of ordinary skill in the relevant arts. The embodiments were chosen and described in order to best explain the principles of the invention and its practical application, thereby enabling others skilled in the art to understand the invention for various embodiments and with various modifications that are suited to the particular use contemplated. It is intended that the scope of the invention be defined by the claims and their equivalence.
Patent Citations
Cited PatentFiling datePublication dateApplicantTitle
US5499371 *Mar 22, 1995Mar 12, 1996Persistence Software, Inc.Method and apparatus for automatic generation of object oriented code for mapping relational data to objects
US6199195 *Jul 8, 1999Mar 6, 2001Science Application International CorporationAutomatically generated objects within extensible object frameworks and links to enterprise resources
US6266666 *Sep 8, 1998Jul 24, 2001Sybase, Inc.Component transaction server for developing and deploying transaction- intensive business applications
US6308179 *Aug 31, 1998Oct 23, 2001Xerox CorporationUser level controlled mechanism inter-positioned in a read/write path of a property-based document management system
US6442541 *Jun 28, 1999Aug 27, 2002International Business Machines CorporationUniversal database adapters
US6466933 *Sep 21, 1999Oct 15, 2002International Business Machines CorporationDelayed delivery of query results or other data from a federated server to a federated client until such information is needed
US6505200 *Jul 6, 2000Jan 7, 2003International Business Machines CorporationApplication-independent data synchronization technique
US6694328 *Jan 13, 2000Feb 17, 2004International Business Machines CorporationMethod for creating queries on version objects
US6748373 *Sep 17, 2002Jun 8, 2004Bea Systems, Inc.System and method for adaptively optimizing queries
US6760719 *Sep 24, 1999Jul 6, 2004Unisys Corp.Method and apparatus for high speed parallel accessing and execution of methods across multiple heterogeneous data sources
US6760812 *Oct 5, 2000Jul 6, 2004International Business Machines CorporationSystem and method for coordinating state between networked caches
US6823329 *Apr 2, 2002Nov 23, 2004Sybase, Inc.Database system providing methodology for acceleration of queries involving functional expressions against columns having enumerated storage
US6836889 *Jul 20, 2000Dec 28, 2004International Business Machines CorporationCode wrapping to simplify access to and use of enterprise JAVA beans
US6971085 *Aug 31, 2000Nov 29, 2005International Business Machines CorporationObject oriented structured query language (OOSQL) support for enterprise java beans
US6985912 *Jul 22, 2003Jan 10, 2006Thought, Inc.Dynamic object-driven database manipulation and mapping system having a simple global interface and an optional multiple user need only caching system with disable and notify features
US6996565 *Sep 4, 2002Feb 7, 2006Initiate Systems, Inc.System and method for dynamically mapping dynamic multi-sourced persisted EJBs
Referenced by
Citing PatentFiling datePublication dateApplicantTitle
US6999956 *Nov 15, 2001Feb 14, 2006Ward MullinsDynamic object-driven database manipulation and mapping system
US7412455Apr 30, 2004Aug 12, 2008Dillon David MSoftware framework that facilitates design and implementation of database applications
US7454438Mar 30, 2006Nov 18, 2008Bea Systems, Inc.System and methods for dynamic querying
US7496569 *Aug 29, 2003Feb 24, 2009Sap AgDatabase access statement parser
US7529759 *Oct 15, 2004May 5, 2009Bea Systems, Inc.System and method for batch operation of CMP beans
US7587417Mar 30, 2006Sep 8, 2009Bea Systems, Inc.Systems and methods for dynamic querying
US7631303 *Jun 7, 2004Dec 8, 2009Sap AktiengesellschaftSystem and method for a query language mapping architecture
US8825702 *Feb 24, 2004Sep 2, 2014Oracle International CorporationSending control information with database statement
US9009195 *Jun 17, 2008Apr 14, 2015Rpx CorporationSoftware framework that facilitates design and implementation of database applications
US20020091702 *Nov 15, 2001Jul 11, 2002Ward MullinsDynamic object-driven database manipulation and mapping system
US20040220956 *Apr 30, 2004Nov 4, 2004Dillon Software Services, LlcSoftware framework that facilitates design and implementation of database applications
US20050050040 *Aug 29, 2003Mar 3, 2005Dietmar TheobaldDatabase access statement parser
US20050187958 *Feb 24, 2004Aug 25, 2005Oracle International CorporationSending control information with database statement
US20050262072 *Oct 15, 2004Nov 24, 2005Bea Systems, Inc.System and method for batch operation of CMP beans
US20060004831 *Jun 7, 2004Jan 5, 2006Dirk DebertinSystem and method for a query language mapping architecture
US20060053087 *Jun 8, 2004Mar 9, 2006Pavlov Vladimir KSystem and method for deploying enterprise components using deployment descriptors
US20060173832 *Mar 30, 2006Aug 3, 2006Bea Systems, Inc.Systems and methods for dynamic querying
US20060173835 *Mar 30, 2006Aug 3, 2006Bea System, Inc.System and methods for dynamic querying
US20080249972 *Jun 17, 2008Oct 9, 2008Dillon David MSoftware framework that facilitates design and implementation of database applications
Classifications
U.S. Classification1/1, 707/E17.005, 707/999.003
International ClassificationG06F17/30, G06F9/45, G06F7/00
Cooperative ClassificationY10S707/99933, G06F17/30386, Y10S707/99944
European ClassificationG06F17/30S4
Legal Events
DateCodeEventDescription
May 5, 2003ASAssignment
Owner name: BEA SYSTEMS, INC., CALIFORNIA
Free format text: ASSIGNMENT OF ASSIGNORS INTEREST;ASSIGNORS:SHINN, MATTHEW;WHITE, SETH;WOOLLEN, ROB;REEL/FRAME:014029/0714
Effective date: 20030423