@Override public void execute(ListInsertable insertable) { final List<Insert> inserts = insertable.getInserts(); atomicInsert.of(new AtomicInsertOperation() { @Override public void execute(Insertion insertion) throws SQLException { for (Insert insert : inserts) { insertion.of(insert); } } }); }
@Override public void execute(AbstractListInsertable insertable) { final List<? extends AbstractInsert<?>> inserts = insertable.getInserts(); atomicInsert.of(new AtomicInsertOperation() { @Override public void execute(Insertion insertion) throws SQLException { for (AbstractInsert<?> insert : inserts) { insertion.of(insert); } } }); }
@Override public void execute(AbstractListInsertable insertable) { final List<? extends AbstractInsert<?>> inserts = insertable.getInserts(); atomicInsert.of(new AtomicInsertOperation() { @Override public void execute(Insertion insertion) throws SQLException { for (AbstractInsert<?> insert : inserts) { insertion.of(insert); } } }); }
@Override public <T> T of(T entity, Supplier<T> finder) { try { atomicInsert.of(entity); return entity; } catch (InsertOperationException e) { if (e.isIntegrityViolation()) { T existing = finder.get(); if (existing == null) { throw new UniqueInsertOperationException("Tried to return found entity but got null", e); } if (!entity.equals(existing)) { throw new UniqueInsertOperationException("Found entity is not equal to supplied entity. " + "Maybe you forgot to implement equals() and hashCode()", e); } return existing; } else { throw e; } } }
@Override public <T> T of(T entity, Supplier<T> finder) { try { atomicInsert.of(entity); return entity; } catch (InsertOperationException e) { if (e.isIntegrityViolation()) { T existing = finder.get(); if (existing == null) { throw new UniqueInsertOperationException("Tried to return found entity but got null", e); } if (!entity.equals(existing)) { throw new UniqueInsertOperationException("Found entity is not equal to supplied entity. " + "Maybe you forgot to implement equals() and hashCode()", e); } return existing; } else { throw e; } } }
@Override public <T> T of(T entity, Supplier<T> finder) { try { atomicInsert.of(entity); return entity; } catch (InsertOperationException e) { if (e.isIntegrityViolation()) { T existing = finder.get(); if (existing == null) { throw new UniqueInsertOperationException("Tried to return found entity but got null", e); } if (!entity.equals(existing)) { throw new UniqueInsertOperationException("Found entity is not equal to supplied entity. " + "Maybe you forgot to implement equals() and hashCode()", e); } return existing; } else { throw e; } } }