Dao implements JdbcExecutor { public abstract int executeNamedUpdate(String sqlKey, Object[] args);  static Dao get(); static Dao get(String name); static Dao of(Class<?> entityClass); EntityMapping getEntityMapping(String name); DbDialect getDialect(); abstract OrmContext getOrmContext(); abstract JdbcExecutor getJdbcExecutor(); abstract Errors validate(Object entity); abstract Errors validate(Object entity, int maxErrors); abstract Errors validate(EntityMapping em, Object entity); abstract Errors validate(EntityMapping em, Object entity, Iterable<String> fields); abstract Errors validate(EntityMapping em, Object entity, int maxErrors); abstract Errors validate(EntityMapping em, Object entity, int maxErrors, Iterable<String> fields); abstract InsertCommand cmdInsert(Class<?> entityClass); abstract InsertCommand cmdInsert(String entityName); abstract InsertCommand cmdInsert(EntityMapping em); abstract UpdateCommand cmdUpdate(Class<?> entityClass); abstract UpdateCommand cmdUpdate(String entityName); abstract UpdateCommand cmdUpdate(EntityMapping em); abstract DeleteCommand cmdDelete(EntityMapping em, Object id); abstract CascadeDeleteCommand cmdCascadeDelete(EntityMapping em, Object id); abstract int insert(Object entity); abstract int insert(Class<?> entityClass, Object entity); abstract int insert(String entityName, Object entity); int insert(EntityMapping em, Object entity); abstract int insert(EntityMapping em, Object entity, Object id); abstract int update(Object entity); abstract int update(Class<?> entityClass, Object entity); abstract int update(String entityName, Object entity); abstract int update(EntityMapping em, Object entity); abstract int update(Object entity, Map<String, Object> fields); abstract int update(Class<?> entityClass, Object id, Map<String, Object> fields); abstract int update(String entityName, Object id, Map<String, Object> fields); abstract int update(EntityMapping em, Object id, Map<String, Object> fields); abstract int updateSelective(Object entity); abstract int updateSelective(Class<?> entityClass, Object entity); abstract int updateSelective(String entityName, Object entity); abstract int updateSelective(EntityMapping em, Object entity); abstract int updateSelective(Object entity, Map<String, Object> fields); abstract int updateSelective(Class<?> entityClass, Object id, Map<String, Object> fields); abstract int updateSelective(String entityName, Object id, Map<String, Object> fields); abstract int updateSelective(EntityMapping em, Object id, Map<String, Object> fields); abstract int delete(Object entity); abstract int delete(Class<?> entityClass, Object id); abstract int delete(String entityName, Object id); abstract int delete(EntityMapping em, Object id); abstract boolean cascadeDelete(Class<?> entityClass, Object id); abstract boolean cascadeDelete(String entityName, Object id); abstract boolean cascadeDelete(EntityMapping em, Object id); abstract int deleteAll(Class<?> entityClass); abstract int deleteAll(String entityName); abstract int deleteAll(EntityMapping em); abstract T find(Class<T> entityClass, Object id); abstract Record find(String entityName, Object id); abstract Record find(EntityMapping em, Object id); abstract T find(Class<?> entityClass, Class<T> resultClass, Object id); abstract T find(String entityName, Class<T> resultClass, Object id); abstract T find(EntityMapping em, Class<T> resultClass, Object id); abstract T findOrNull(Class<T> entityClass, Object id); abstract Record findOrNull(String entityName, Object id); abstract Record findOrNull(EntityMapping em, Object id); abstract T findOrNull(Class<?> entityClass, Class<T> resultClass, Object id); abstract T findOrNull(String entityName, Class<T> resultClass, Object id); abstract T findOrNull(EntityMapping em, Class<T> resultClass, Object id); abstract List<T> findList(Class<T> entityClass, Object[] ids); abstract List<Entity> findList(String entityName, Object[] ids); abstract List<T> findList(String entityName, Class<T> resultClass, Object[] ids); abstract List<T> findList(EntityMapping em, Class<T> resultClass, Object[] ids); abstract List<T> findListIfExists(Class<T> entityClass, Object[] ids); abstract List<Record> findListIfExists(String entityName, Object[] ids); abstract List<T> findListIfExists(String entityName, Class<T> resultClass, Object[] ids); abstract List<T> findListIfExists(EntityMapping em, Class<T> resultClass, Object[] ids); abstract List<T> findAll(Class<T> entityClass); List<Record> findAll(String entityName); abstract List<T> findAll(String entityName, Class<T> resultClass); abstract boolean exists(Class<?> entityClass, Object id); abstract boolean exists(String entityName, Object id); abstract long count(Class<?> entityClass); abstract long count(String entityName); abstract long count(EntityMapping em); abstract int executeUpdate(SqlCommand command, Object[] args); abstract int executeUpdate(SqlCommand command, Object bean); abstract int executeUpdate(SqlCommand command, Map params); abstract int executeUpdate(String sql, Object bean); abstract int executeUpdate(String sql, Map params); abstract int executeNamedUpdate(String sqlKey, Object[] args); abstract int executeNamedUpdate(String sqlKey, Object bean); abstract int executeNamedUpdate(String sqlKey, Map<String, Object> params); abstract Query<Record> createQuery(SqlCommand command); abstract Query<T> createQuery(Class<T> resultClass, SqlCommand command); SqlCommand createSqlCommand(String sql); abstract Query<Record> createSqlQuery(String sql); abstract Query<Record> createSqlQuery(String sql, Object... args); abstract Query<T> createSqlQuery(Class<T> resultClass, String sql); abstract EntityQuery<Record> createSqlQuery(EntityMapping em, String sql); abstract EntityQuery<T> createSqlQuery(EntityMapping em, Class<T> resultClass, String sql); abstract NativeQuery<Record> createNativeQuery(String sql); abstract NativeQuery<Record> createNativeQuery(String sql, Object... args); abstract NativeQuery<T> createNativeQuery(Class<T> resultClass, String sql); abstract NativeQuery<T> createNativeQuery(Class<T> resultClass, String sql, Object... args); abstract CriteriaQuery<T> createCriteriaQuery(Class<T> entityClass); abstract CriteriaQuery<Record> createCriteriaQuery(String entityName); abstract CriteriaQuery<Record> createCriteriaQuery(EntityMapping em); abstract CriteriaQuery<T> createCriteriaQuery(EntityMapping em, Class<T> resultClass); abstract CriteriaQuery<T> createCriteriaQuery(Class<?> entityClass, Class<T> resultClass); abstract Query<Record> createNamedQuery(String queryName); abstract Query<T> createNamedQuery(String queryName, Class<T> resultClass); @Deprecated abstract EntityQuery<T> createNamedQuery(Class<T> entityClass, String queryName); @Deprecated abstract EntityQuery<Record> createNamedQuery(String entityName, String queryName); @Deprecated abstract EntityQuery<T> createNamedQuery(String entityName, Class<T> resultClass, String queryName); @Deprecated abstract EntityQuery<T> createNamedQuery(EntityMapping em, Class<T> resultClass, String queryName); abstract int[] batchInsert(List<?> entities); abstract int[] batchInsert(Object[] entities); abstract int[] batchInsert(String entityName, List<?> records); abstract int[] batchInsert(String entityName, Object[] records); abstract int[] batchInsert(Class<?> entityClass, List<?> records); abstract int[] batchInsert(Class<?> entityClass, Object[] records); abstract int[] batchInsert(EntityMapping em, List<?> records); abstract int[] batchInsert(EntityMapping em, Object[] records); abstract int[] batchUpdate(List<?> entities); abstract int[] batchUpdate(Object[] entities); abstract int[] batchUpdate(String entityName, List<?> records); abstract int[] batchUpdate(String entityName, Object[] records); abstract int[] batchUpdate(Class<?> entityClass, List<?> records); abstract int[] batchUpdate(Class<?> entityClass, Object[] records); abstract int[] batchUpdate(EntityMapping em, List<?> records); abstract int[] batchUpdate(EntityMapping em, Object[] records); abstract int[] batchDelete(String entityName, List<?> ids); abstract int[] batchDelete(String entityName, Object[] ids); abstract int[] batchDelete(Class<?> entityClass, List<?> ids); abstract int[] batchDelete(Class<?> entityClass, Object[] ids); abstract int[] batchDelete(EntityMapping em, List<?> ids); abstract int[] batchDelete(EntityMapping em, Object[] ids); abstract void doTransaction(TransactionCallback callback); abstract T doTransaction(TransactionCallbackWithResult<T> callback); abstract void doTransaction(TransactionCallback callback, boolean requiresNew); abstract void doTransaction(TransactionCallback callback, TransactionDefinition definition); abstract T doTransaction(TransactionCallbackWithResult<T> callback, boolean requiresNew); abstract void withEvents(Runnable func); abstract T withEvents(Supplier<T> func); abstract void withoutEvents(Runnable func); abstract T withoutEvents(Supplier<T> func); abstract boolean isWithEvents();  }
@Test public void testExecuteNamedUpdate() { deleteAll(Owner.class); if(db.getPlatform() instanceof OraclePlatform){ assertEquals(1,dao.executeNamedUpdate("simpleInsertOwner_oracle", new Object[]{1,"a","b", new Date(),new Date()})); }else{ assertEquals(1,dao.executeNamedUpdate("simpleInsertOwner", new Object[]{"a","b", new Date(),new Date()})); } assertEquals(1, Owner.count()); deleteAll(Owner.class); Map<String, Object> params = new HashMap<String, Object>(); params.put("id",2); params.put("firstName", "c"); params.put("lastName", "d"); params.put("now", new Date()); if(db.getPlatform() instanceof OraclePlatform){ assertEquals(1, dao.executeNamedUpdate("simpleInsertOwner1_oracle",params)); }else{ assertEquals(1, dao.executeNamedUpdate("simpleInsertOwner1",params)); } assertEquals(1, Owner.count()); }