Skip to main content

Executing a Class Query

The system automatically generates a method for each Class Query in a Caché class and adds it to the Java Projection. Caché forms the method's name by prepending “query_” to the name of the Caché query. The Java method returns an object of type com.intersys.objects.CacheQuery.

For example, the Caché Contact class contains a Class Query named RetrieveByContactType. Caché adds a method with the following signature to the Java Projection:

public static CacheQuery query_RetrieveByContactType (Database db) 
throws CacheException

Use the CacheQuery execute method to execute the query. The following Java method uses the Java Projection to execute the RetrieveByContactType query. The method passes type to the query as the value of its input parameter.

public class BindingExamples {
   public static void displayContactsByType(Database db, String type)
   throws CacheException, SQLException{
      CacheQuery query = Contact.query_RetrieveByContactType(db);
      java.sql.ResultSet rs=query.execute(type);
      System.out.println(type + " Contacts");
      while ({

In order for a Caché class query to be projected to Java, it must include the SqlProc keyword.

The com.intersys.classes package contains a ResultSet class. This class is deprecated and should not be used.

The fully qualified name of java.sql.ResultSet must be used to prevent ambiguity in the event that com.intersys.classes has been imported into the source file.

FeedbackOpens in a new tab