SQLComments implements support for Spring. AbstractSQLCommentsRepository extends class JdbcDaoSupport and add some shortcuts for often tasks and CRUD operations.

CRUD methods and method findByPK are expecting that some configuration classes and statement files already exists. Use SQL Comments Maven plugin with goal domain to generate appropriate classes and files:

  • domain configuration class - <T>Config.java
  • primary key configuration class - <T>PKConfig.java
  • domain mapper class - <T>Mapper.java
  • insert statement file - <T>.insert.sql
  • update statement file - <T>.update.sql
  • delete statement file - <T>.delete.sql
  • findByPK statement file - <T>.findByPK.sql

For example for table called 'COMPANIES' will be generated files:

  • CompaniesConfig.java
  • CompaniesPKConfig.java
  • CompaniesMapper.java
  • Companies.insert.sql
  • Companies.update.sql
  • Companies.delete.sql
  • Companies.findByPK.sql

For more usefull methods see AbstractSQLCommentsRepository Java API.

See also tutorial How to Create Repository Class with Spring.