T - T is Class that have @Entity Annotationpublic class JKHibernateServices<T>
extends java.lang.Object
| Constructor and Description |
|---|
JKHibernateServices(java.lang.Class<T> classObject,
JKHibernateBuilder hibernateBuilder) |
| Modifier and Type | Method and Description |
|---|---|
org.hibernate.Transaction |
beginTransaction()
begin the transaction process
|
void |
cancelQuery()
cancel the current execution of the query
|
void |
close()
close the session
|
void |
commit()
commit all objects that in the session
to make impact in the database |
org.hibernate.Query |
createQuery(java.lang.String hql)
create HQL
|
org.hibernate.SQLQuery |
createSQLQuery(java.lang.String sql)
create SQL query in the database
|
void |
delete(T... objects)
take the classes that has @Entity Annotation
and delete them from the session to be deleted from the database after use commit commit() method |
void |
deleteById(java.io.Serializable id)
delete object with it's primary key
after use commit
commit() method |
void |
flush()
flush all objects that in the session
to make impact in the database after use commit commit() method |
T |
get(java.io.Serializable id)
get object from database by the primary key
|
java.util.List<T> |
get(java.lang.String hqlQuery)
get a list from database
depends on the hqlQuery query |
java.util.List<T> |
getAll()
get all in the database table
depend on the T class like SELECT * FROM table_name in SQL Command |
JKHibernateBuilder |
getHibernateBuilder() |
java.lang.Class<T> |
getHibernatedClass() |
org.hibernate.Session |
getSession() |
java.lang.Object[] |
insert(T... objects)
take the classes that has @Entity Annotation
and add them to the session to be added to the database after use commit commit() method |
void |
insertOrUpdate(T... objects)
take the classes that has @Entity Annotation
and add them to the session to be inserted to the database if not exists or updated if exists after use commit commit() method |
T |
load(java.io.Serializable id)
load object from the database
You should use
get(Serializable) method if you are not certain that the object exits in database |
void |
refresh(T... objects)
refresh the objects in the database
|
void |
rollback()
to rollback for any saved , updated, deleted objects in the session
|
void |
setHibernateBuilder(JKHibernateBuilder hibernateBuilder)
reset the current hibernateBuilder
|
void |
setHibernatedClass(java.lang.Class<T> hibernatedClass)
reset the current hibernatedClass
|
void |
setSession(org.hibernate.Session session)
reset the current session
|
void |
update(T... objects)
take the classes that has @Entity Annotation
and update them in the session to be updated in the database after use commit commit() method |
public JKHibernateServices(java.lang.Class<T> classObject, JKHibernateBuilder hibernateBuilder)
classObject - class of the T class that have @Entity AnnotationshibernateBuilder - instance of the Hibernate Builder classpublic java.util.List<T> getAll()
public java.util.List<T> get(java.lang.String hqlQuery)
hqlQuery - HQL Query request from the databasepublic T get(java.io.Serializable id)
id - Primary key for the class , may be compound keypublic T load(java.io.Serializable id)
get(Serializable) method id - Primary key for the class , may be compound keypublic void refresh(T... objects)
objects - T objects for be refresh from dbpublic java.lang.Object[] insert(T... objects)
commit() methodobjects - T objects to be save to sessionSessionpublic void insertOrUpdate(T... objects)
commit() methodobjects - T objects to be saveOrUpdate in sessionSessionpublic void update(T... objects)
commit() methodobjects - T objects to be update in sessionSessionpublic void deleteById(java.io.Serializable id)
commit() methodid - Primary key for the class , may be compound keypublic void delete(T... objects)
commit() methodobjects - T objects to be deleted from sessionSessionpublic org.hibernate.Query createQuery(java.lang.String hql)
hql - HQL Query statment for request from dbQuerypublic org.hibernate.SQLQuery createSQLQuery(java.lang.String sql)
sql - QL Query statment for request from dbSessionpublic void cancelQuery()
Sessionpublic org.hibernate.Transaction beginTransaction()
Sessionpublic void commit()
Sessionpublic void flush()
commit() methodSessionpublic void rollback()
Sessionpublic void close()
Sessionpublic org.hibernate.Session getSession()
Sessionpublic void setSession(org.hibernate.Session session)
session - public java.lang.Class<T> getHibernatedClass()
public void setHibernatedClass(java.lang.Class<T> hibernatedClass)
hibernatedClass - public JKHibernateBuilder getHibernateBuilder()
public void setHibernateBuilder(JKHibernateBuilder hibernateBuilder)
hibernateBuilder - the hibernateBuilder to set