E
- a class that has an @Entity
annotationK
- the key for that class, which will have the @Id
annotation in the associated {@link Entitypublic class DataBean<E,K> extends Object
Modifier and Type | Field and Description |
---|---|
static int |
RECORDS_PER_PAGE |
Constructor and Description |
---|
DataBean() |
Modifier and Type | Method and Description |
---|---|
void |
delete(E e) |
E |
find(K key)
Returns the entity associated with the primary key.
|
int |
getNumPages()
Returns the number of pages available.
|
int |
getPage()
Returns the page number.
|
String |
getSort()
Returns the current sort String.
|
void |
initialize(Class<E> clazz)
This method should be called before any other method is called.
|
List<E> |
list()
Returns a list of the entities.
|
K |
save(E e) |
void |
setPage(int page)
Sets the page number.
|
void |
setSort(String sort)
Sets the sort String.
|
void |
update(E e) |
public static final int RECORDS_PER_PAGE
public void initialize(Class<E> clazz)
@EJB
annotation
using a no-argument constructor.
The Class
object must be the same type specified by E. This class must have both an {@link Entity
clazz
- a Class
object of the same type specified by EIllegalArgumentException
- if the class clazz does not have an @Entity
annotation or field
public static final String FIND_ALL
public String getSort()
The sort string is actually a query of sorts (pun intended?) where, when list()
is called, is sorted in a
way where the string is seperated into a string array by the period (".") character, and then the query result is
sorted by the first element of the string array, then the next element, and so on.
public void setSort(String sort)
The sort string is actually a query of sorts (pun intended?) where, when list()
is called, is sorted in a
way where the string is seperated into a string array by the period (".") character, and then the query result is
sorted by the first element of the string array, then the next element, and so on.
sort
- the sort Stringpublic int getPage()
public void setPage(int page)
page
- the page numberpublic int getNumPages()
RECORDS_PER_PAGE
, where RECORDS_PER_PAGE
is currently set to 50.public List<E> list()
RECORDS_PER_PAGE
, which is currently set
to 50.public E find(K key)
key
- the primary keypublic void update(E e)
e
- public void delete(E e)
e
- Copyright © 2015 Joseph Hendrix