Logically combining interfaces to reduce the number of DB2 packages that you must manage

You can create an interface that extends one or more interfaces that declare annotated methods, and use the pureQuery Generator utility to generate an implementation class from that extending interface.

The extending interface can also declare annotated methods. When you then run the pureQuery StaticBinder on the extending interface, you create and bind a DB2® package that contains the SQL statements from the extended interfaces and, if it declares annotated methods, the extending interface.

By following this procedure, you reduce the number of DB2 packages that you need to manage.

Attention: .

Example

Suppose that you have the following interfaces:
public interface SalesTeam { 
     @Select(sql="SELECT * FROM SALES") 
     List<SalesBean> getSalesEmployees(); 
}
   
public interface MarketingTeam { 
     @Select(sql="SELECT * FROM MARKETING") 
     List<MktBean> getMarketingEmployees(); 
}
You want to bind the SQL statements in these interfaces into a single DB2 package. You can do so by following these steps:
  1. Create an interface that extends SalesTeam and MarketingTeam. For this example, the name of the interface is CombinedTeam and the interface looks like this:
    public interface CombinedTeam extends SalesTeam, MarketingTeam { 
       @Select("select sales/expense from dept where dept_id=?")
       public double getROIforDept(int dept_id);
    }
  2. Generate the implementation class for the CombinedTeam interface by running the pureQuery Generator utility. This implementation class contains the methods that are declared in the SalesTeam and MarketingTeam interfaces.
  3. Run the pureQuery StaticBinder utility on the generated implementation class by specifying the combined interface.

Feedback