Search in sources :

Example 1 with EntityValueResult

use of org.qi4j.entitystore.sql.internal.DatabaseSQLService.EntityValueResult in project qi4j-sdk by Qi4j.

the class SQLEntityStoreMixin method getValue.

protected EntityValueResult getValue(EntityReference ref) {
    Connection connection = null;
    PreparedStatement ps = null;
    ResultSet rs = null;
    try {
        connection = database.getConnection();
        ps = database.prepareGetEntityStatement(connection);
        database.populateGetEntityStatement(ps, ref);
        rs = ps.executeQuery();
        if (!rs.next()) {
            throw new EntityNotFoundException(ref);
        }
        EntityValueResult result = database.getEntityValue(rs);
        return result;
    } catch (SQLException sqle) {
        throw new EntityStoreException("Unable to get Entity " + ref, sqle);
    } finally {
        SQLUtil.closeQuietly(rs);
        SQLUtil.closeQuietly(ps);
        SQLUtil.closeQuietly(connection);
    }
}
Also used : EntityValueResult(org.qi4j.entitystore.sql.internal.DatabaseSQLService.EntityValueResult) SQLException(java.sql.SQLException) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) EntityNotFoundException(org.qi4j.spi.entitystore.EntityNotFoundException) EntityStoreException(org.qi4j.spi.entitystore.EntityStoreException)

Aggregations

Connection (java.sql.Connection)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 EntityValueResult (org.qi4j.entitystore.sql.internal.DatabaseSQLService.EntityValueResult)1 EntityNotFoundException (org.qi4j.spi.entitystore.EntityNotFoundException)1 EntityStoreException (org.qi4j.spi.entitystore.EntityStoreException)1