Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.
public interface CrudRepository<E, K>
Base contract for generated repositories. The caller owns the Session and transaction.
save returns the managed merge result; insert schedules a new instance for persistence.
Methods
Method details
findById
public abstract E findById(K id)save
public abstract E save(E entity)insert
public abstract void insert(E entity)deleteById
public abstract void deleteById(K id)findAll
public abstract List<E> findAll()count
public abstract long count()existsById
public abstract boolean existsById(K id)delete
public abstract void delete(E entity)Deletes one entity, managed or detached, as Spring Data’s
delete does: a
detached instance is merged first, so the row it stands for is removed. An
entity whose row no longer exists is ignored. Requires a transaction.deleteAll
public abstract void deleteAll()Deletes every entity of this type, one by one, so cascades and lifecycle
callbacks run as they do for
delete. Requires a transaction.deleteAll
public abstract void deleteAll(Iterable<? extends E> entities)Deletes each of the given entities, as
delete does. Requires a transaction.saveAll
public abstract List<E> saveAll(Iterable<? extends E> entities)Saves each of the given entities, as
save does, and answers the managed
results in the same order.findAllById
public abstract List<E> findAllById(Iterable<K> ids)The entities whose ids are given, in the order given; an id with no row is
skipped, so the list can be shorter than the input.
flush
public abstract void flush()Writes pending changes of the caller’s session now, rather than at commit.