Browse DevX
Sign up for e-mail newsletters from DevX


Java Data Objects (JDO): An Object-based Approach to Transparent Persistence : Page 3

For persistence storages, JDO provides a better and more efficient approach to application development.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

JDO Query Example
The sample JDO query example is a Web-based real estate property search-and-browse application called PropertySearch. The sample application demonstrates the powerful features of JDOQL and JDO's transparent persistence capabilities. You can deploy the sample application onto any J2EE-compliant Web container. PropertySearch also illustrates how the JDO Query interface makes complex Java-based queries completely data-store-neutral.

PropertySearch has a browser front end. The starting URL for the application is "SearchProperty.html". Figure 2 shows the main search/query page.

Figure 2 | The main search/query page of PropertySearch

PropertySearch has the following features and limitations (the limitations are by design to keep things simple):

  • Users can filter properties by specifying any combination of State, City, and Property Type.
  • Users can limit the results by specifying either the maximum price or the minimum number of bedrooms.
  • If the user does not specify search criteria and clicks the "Find Properties" button, PropertySearch displays a list of all available properties (default search).
  • The application does not handle exceptions, including any JDO runtime exceptions.
  • The dataset provided with the sample is quite small, but you can easily extend it.

    The PropertySearch application consists of a single Web module containing a Java Bean, two JSP pages, an HTML page, and a few JAR files. Figure 3 shows the PropertySearch architecture.

    Figure 3 | Architectural view of the PropertySearch Web application

    Here's how each file functions in the application:

  • SearchProperty.html - The main HTML page for the application (see Figure 2)
  • SearchProperties.jsp - A JSP page that accepts query information submitted from PropertySearch.html, uses JDO query APIs and the SearchPropertiesBean to access the backend RDBMS, then dynamically formats the property listings returned from the database
  • SearchMoreInfo.jsp - A JSP page that returns detail property information when the user selects a specific property
  • SearchPropertiesBean.java - A helper Bean class that makes the database connection, builds the query based on user criteria, and executes the query using JDO Query and Transaction interfaces
  • PropertyClass.jar - A JAR file created by compiling and enhancing the mapped Java class Property.java, which represents the backend database Property table residing in the data store

  • Comment and Contribute






    (Maximum characters: 1200). You have 1200 characters left.



    Thanks for your registration, follow us on our social networks to keep up-to-date