Table of Contents
Prerequisites
- caGrid data service generated by Introduce
- JavaEE IDE (Eclipse was used in the following tutorial) NOTE: Any other Java IDE would be compatible too. but since, Introduce auto-generates an Eclipse project while creating the caGrid Data Service, its convenient to build query clients in Eclipse for the data service
Import Project
To import the project into the Eclipse workspace
- File -> Import -> Existing Projects into Workspace
- Browse to the location where you saved the Introduce created data service in step 6 of generating the domain model
- Click Finish
Create Query Classes
We will form a query using the Hibernate Query Language (HQL). We've already created the required classes, HibernateUtil.java and PeopleClient.java when we created a query client for the People object model. We will just copy these same two classes for querying the grid data service.
NOTE: The only difference between the two query clients is that one is local while the other is remote i.e., the query client for the object model is local (need not start tomcat) and the query client for the Introduce created grid data service is remote (need to start tomcat)
- Expand project Person in Eclipse and navigate to src -> edu.uab.uabgrid.cacoresdk.domain package
- Select the package -> Right Click -> New -> class
- Type the class Name as HibernateUtil.java -> Finish
- Copy this java code and paste to the above created HibernateUtil.java
- Make sure that the first line in the above class is the package name package edu.uabgrid.uab.cacoresdk.domain to preserve the namespace
- Save project Ctrl-S
Now, create the class which forms a query and lists the contents of the single table data service People
- Repeat steps 1 and 2 above to create a new class
- Type the class Name as PeopleClient.java -> Finish
- Copy this java code and paste to the above created PeopleClient.java
- Make sure that the first line in the above class is the package name package edu.uabgrid.uab.cacoresdk.domain to preserve the namespace
- Save project Ctrl-S
Add External Jar
Since, we are building our query with HQL and since, Introduce does not provision the Eclipse project for the caGrid data service with Hibernate mappings file for the grid data service, we need to explicitly add the required jar. This jar file is the same <obj-name>-orm.jar file created during the object model generation using caCORESDK. If we assume that your caCORE SDK has been installed at /home/user/src/caCORE, then for the People object model created in part 1 of this tutorial the related hibernate mappings jar will be located at
/home/user/src/caCORE/output/person/package/local-client/lib/person-orm.jar
To add the above jar file to the Person grid data service in Eclipse,
- Select project Person -> Right Click -> Properties
- In the Properties window -> select Java Build Path -> Click on the tab Libraries
- Click on the tab Add External Jars
- Navigate to the above specified location to add the person-orm.jar
- Click OK -> OK
- You will now see the person-orm.jar listed under the Referenced Libraries folder
Start Tomcat
Start tomcat via the Eclipse plugin or from command line
$CATALINA_HOME/bin/startup.sh
Execute the Query
- In Eclipse, navigate to Person -> src -> edu.uabgrid.uab.cacoresdk.domain
- Select PeopleClient.java -> Right Click -> Run As -> Java Application
- The console will list the objects in the table PERSON of the Person caGrid data service
Check the Data Service Registration
Troubleshoot caGrid Index Service Registration. Perform diagnostic checks for the data service published to caGrid-1.3 training index service









