Lutece 8 DAO and Home layer patterns: DAOUtil lifecycle, SQL constants, Home static facade, CDI lookup, collection types, interface conventions. MUST be consulted before creating or modifying DAO/Home classes.
View on GitHubskills/lutece-dao/SKILL.md
February 5, 2026
Select agents to install to:
npx add-skill https://github.com/lutece-platform/lutece-dev-plugin-claude/blob/main/skills/lutece-dao/SKILL.md -a claude-code --skill lutece-daoInstallation paths:
.claude/skills/lutece-dao/# DAO & Home Patterns — Lutece 8
> Before writing DAO or Home code, consult `~/.lutece-references/lutece-core/` and `~/.lutece-references/lutece-form-plugin-forms/` using Read, Grep and Glob.
## DAO Class Structure
```java
@ApplicationScoped
@Named( "myplugin.entityDAO" )
public class EntityDAO implements IEntityDAO
{
private static final String SQL_QUERY_NEWPK = "SELECT max( id_entity ) FROM myplugin_entity";
private static final String SQL_QUERY_SELECT = "SELECT id_entity, title, description FROM myplugin_entity WHERE id_entity = ?";
private static final String SQL_QUERY_INSERT = "INSERT INTO myplugin_entity ( id_entity, title, description ) VALUES ( ?, ?, ? )";
private static final String SQL_QUERY_UPDATE = "UPDATE myplugin_entity SET title = ?, description = ? WHERE id_entity = ?";
private static final String SQL_QUERY_DELETE = "DELETE FROM myplugin_entity WHERE id_entity = ?";
private static final String SQL_QUERY_SELECTALL = "SELECT id_entity, title, description FROM myplugin_entity";
// ...
}
```
## SQL Constant Naming
| Constant | Usage |
|----------|-------|
| `SQL_QUERY_NEWPK` | `SELECT max(id_xxx) FROM table` |
| `SQL_QUERY_SELECT` | Single row by PK |
| `SQL_QUERY_INSERT` | Insert row |
| `SQL_QUERY_UPDATE` | Update row by PK |
| `SQL_QUERY_DELETE` | Delete row by PK |
| `SQL_QUERY_SELECTALL` | All rows |
| `SQL_QUERY_SELECT_BY_*` | Custom finders |
| `SQL_QUERY_COUNT_*` | Count queries |
## DAOUtil Lifecycle
Always use **try-with-resources** (auto-closes):
### INSERT / UPDATE / DELETE
```java
public void insert( Entity entity, Plugin plugin )
{
try ( DAOUtil daoUtil = new DAOUtil( SQL_QUERY_INSERT, plugin ) )
{
int nIndex = 1;
daoUtil.setInt( nIndex++, entity.getId( ) );
daoUtil.setString( nIndex++, entity.getTitle( ) );
daoUtil.setString( nIndex++, entity.getDescription( ) );
daoUtil.executeUpdate( );
}
}
```
### SELECT (single row)
```java
public Entity load( int