Annotated-method interfaces that are generated from SQL statements

When you generate code from a single SQL statement, you can select whether to generate an interface that declares a method that is annotated with that statement. When you generate code from multiple SQL statements, the workbench always generates an annotated-method interface, which declares a method for each statement.

Annotated-method interfaces that are generated from SELECT statements

When you generate an annotated-method interface from a SELECT statement, the interface contains one method. This method has an @Select annotation. The content of the annotation is the original SELECT statement. The method return type is an Iterator of <BeanName>.

The default name of the method is get<Name-of-bean>. You can change this name when you specify the information for generating the interface.

For example, if you generate an interface from the SELECT statement Select * from table where col1 = ?, the interface contains this annotated method:
@Select(sql="Select * from name-of-table where col1 = ?")
Iterator<Name-of-bean> getName-of-bean(int param1);

If you specify the name of a custom RowHandler, an @Handler annotation is included.

@Select(sql="Select * from name-of-table where col1 = ?")
@Handler(rowHandler="Name-of-handler")
Iterator<Name-of-bean> getName-of-bean(int param1);

Annotated-method interfaces that are generated from UPDATE, INSERT, or DELETE statements

When you generate an annotated-method interface from an UPDATE, INSERT, or DELETE statement, the interface contains a method that has an @Update annotation. The content of the annotation is the original UPDATE, INSERT, or DELETE statement. The method return type is an integer.

Annotated-method interfaces that are generated from CALL statements

When you generate an annotated-method interface from a CALL statement, the interface contains a method that has an @Call annotation. The content of the annotation is the original CALL statement.

The method return type is StoredProcedureResult . You can access the JDBC ResultSet from the StoredProcedureResult type.

If you specify the name of a custom CallHandlerWithParameters class, an @Handler annotation is included.

Annotated-method interfaces that are generated from all of the previously mentioned SQL statement types

When you generate an interface from a SELECT, UPDATE, INSERT, DELETE, or CALL statement, the following actions occur:
  • Any host variable names that are contained in the SQL statement are replaced with the standard JDBC parameter marker ("?").
  • The parameter types in a generated method are matched to the parameters in the SQL statement. SQL types are mapped to Java types according to the preferences on the pureQuery Type Mapping page in the Preferences window
  • If you specify the name of an existing annotated-method interface, the method is added into that interface.

Feedback