@DeclareRoles(value="editor") public abstract class AbstractCrudService extends Object implements CrudWriteService
This base class enables you to create minimal crud service beans. All you have to do is override, implement getEntityManager and annotate with
CrudReadService.SORTORDER| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_PAGE_SIZE
default page size (max results), used when no maximum is given.
|
static String |
EDITORROLE |
| Constructor and Description |
|---|
AbstractCrudService() |
| Modifier and Type | Method and Description |
|---|---|
int |
batchCreate(Collection<? extends Serializable> t,
Integer flushCount)
creates multiple entities, when flushCount != null flushes and clears the entitymanager every flushCount entities.
|
int |
batchDelete(Collection<? extends Serializable> t,
Integer flushCount)
deletes multiple entities, when flushCount != null flushes and clears the entitymanager every flushCount entities.
|
int |
batchUpdate(Collection<? extends Serializable> t,
Integer flushCount)
updates multiple entities, when flushCount != null flushes and clears the entitymanager every flushCount entities.
|
int |
count(String namedQuery,
List<Param> params)
|
int |
countDynamic(List<Param> params,
Class type) |
<T extends Serializable> |
create(T t)
When overriding look into
Transactional and roles to use, these
are not inherited. |
void |
delete(Serializable t)
When overriding look into
Transactional and roles to use, these
are not inherited. |
<T extends Serializable> |
find(Serializable id,
Class<T> type) |
<T extends Serializable> |
find(String namedQuery,
List<Param> params,
Integer first,
Integer max,
Class<T> type) |
<T extends Serializable> |
findAll(Class<T> type) |
<T extends Serializable> |
findDynamic(Integer first,
Integer pageSize,
Map<String,CrudReadService.SORTORDER> sort,
List<Param> params,
Class<T> type) |
<T extends Serializable> |
findNative(String namedNativeQuery,
List<Param> params,
Integer first,
Integer max,
Class<T> type) |
<T extends Serializable> |
findOne(String namedQuery,
List<Param> params,
Class<T> type)
return one result or null, multiple results throws an exception
|
protected abstract javax.persistence.EntityManager |
getEntityManager() |
<T extends AbstractEntity> |
save(T t)
create or update depending on
AbstractEntity.isTransient(). |
<T extends Serializable> |
update(T t)
When overriding look into
Transactional and roles to use, these
are not inherited. |
public static final int DEFAULT_PAGE_SIZE
public static final String EDITORROLE
protected abstract javax.persistence.EntityManager getEntityManager()
public <T extends Serializable> T find(Serializable id, Class<T> type)
find in interface CrudReadServicepublic <T extends Serializable> List<T> findAll(Class<T> type)
findAll in interface CrudReadServicepublic <T extends Serializable> List<T> findDynamic(Integer first, Integer pageSize, Map<String,CrudReadService.SORTORDER> sort, List<Param> params, Class<T> type)
findDynamic in interface CrudReadServiceT - first - defaults to 0pageSize - defaults to DEFAULT_PAGE_SIZE, negative value
means no limitsort - params - type - public int countDynamic(List<Param> params, Class type)
countDynamic in interface CrudReadServicepublic <T extends Serializable> List<T> find(String namedQuery, List<Param> params, Integer first, Integer max, Class<T> type)
find in interface CrudReadServiceT - namedQuery - params - first - defaults to 0max - defaults to DEFAULT_PAGE_SIZE, negative value means
no limittype - public <T extends Serializable> List<T> findNative(String namedNativeQuery, List<Param> params, Integer first, Integer max, Class<T> type)
findNative in interface CrudReadServiceT - namedNativeQuery - params - first - max - defaults to DEFAULT_PAGE_SIZE, negative value means
no limittype - public int count(String namedQuery, List<Param> params)
CrudReadServiceCrudReadService.find(java.lang.String, java.util.List, java.lang.Integer, java.lang.Integer, java.lang.Class) or
CrudReadService.findNative(java.lang.String, java.util.List, java.lang.Integer, java.lang.Integer, java.lang.Class).count in interface CrudReadServicepublic <T extends Serializable> T findOne(String namedQuery, List<Param> params, Class<T> type)
CrudReadServicefindOne in interface CrudReadService@RolesAllowed(value="editor") public <T extends Serializable> T create(T t)
Transactional and roles to use, these
are not inherited. If you don't need security, override and use
PermitAll.create in interface CrudWriteServiceT - t - @RolesAllowed(value="editor") public <T extends AbstractEntity> T save(T t)
AbstractEntity.isTransient().save in interface CrudWriteServiceT - t - @RolesAllowed(value="editor") public <T extends Serializable> T update(T t)
Transactional and roles to use, these
are not inherited. If you don't need security, override and use
PermitAll.update in interface CrudWriteServiceT - t - @RolesAllowed(value="editor") public void delete(Serializable t)
Transactional and roles to use, these
are not inherited. If you don't need security, override and use
PermitAll.delete in interface CrudWriteServicet - @RolesAllowed(value="editor") public int batchCreate(Collection<? extends Serializable> t, Integer flushCount)
batchCreate in interface CrudWriteServicet - flushCount - @RolesAllowed(value="editor") public int batchUpdate(Collection<? extends Serializable> t, Integer flushCount)
batchUpdate in interface CrudWriteServicet - flushCount - @RolesAllowed(value="editor") public int batchDelete(Collection<? extends Serializable> t, Integer flushCount)
batchDelete in interface CrudWriteServicet - flushCount - Copyright © 2018 Fryske Akademy. All rights reserved.