Package net.sf.basedb.core
Class LogControl
- java.lang.Object
-
- net.sf.basedb.core.LogControl
-
public class LogControl extends Object
Gives information about the current transaction and gives log implementations limited access to the database.- Version:
- 2.13
- Author:
- Nicklas
- Last modified
- $Date: 2018-11-06 15:50:29 +0100 (ti, 06 nov 2018) $
-
-
Field Summary
Fields Modifier and Type Field Description private int
batchCount
private int
batchSize
private WeakReference<DbControl>
dc
private PreparedStatement
insertIntoDetails
private org.hibernate.StatelessSession
session
private TransactionDetails
transactionDetails
-
Constructor Summary
Constructors Constructor Description LogControl(DbControl dc)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description <R> org.hibernate.query.Query<R>
createHqlQuery(String hql, Class<R> returnType)
Creates a Hibernate HQL query with a known return type.org.hibernate.query.Query<?>
createSqlQuery(String sql)
Deprecated.In 3.12. usecreateSqlQuery(String, Class)
instead<R> org.hibernate.query.Query<R>
createSqlQuery(String sql, Class<R> returnType)
Creates a Hibernate SQL query with a known return type.void
flush()
Flushes any batched changes to the database.private org.hibernate.StatelessSession
getSession()
TransactionDetails
getTransactionDetails()
Get information about the current transaction.void
log(ChangeHistoryData history)
Add a main entry the change history table.void
log(ChangeHistoryDetailData detail)
Adds information about a modified entity to the change history table.
-
-
-
Field Detail
-
dc
private final WeakReference<DbControl> dc
-
transactionDetails
private TransactionDetails transactionDetails
-
session
private org.hibernate.StatelessSession session
-
insertIntoDetails
private PreparedStatement insertIntoDetails
-
batchSize
private final int batchSize
-
batchCount
private int batchCount
-
-
Constructor Detail
-
LogControl
LogControl(DbControl dc)
-
-
Method Detail
-
getTransactionDetails
public TransactionDetails getTransactionDetails()
Get information about the current transaction.- Returns:
- A TransactionDetails object
-
log
public void log(ChangeHistoryData history)
Add a main entry the change history table. Each transaction usually results in one such entry. Changes to individual entities are logged withlog(ChangeHistoryDetailData)
.- Parameters:
history
- A fully initialized ChangeHistoryData object
-
log
public void log(ChangeHistoryDetailData detail)
Adds information about a modified entity to the change history table. The details may not be sent to the database immediately but can be batched for more efficient use of resources.- Parameters:
detail
- A fully initialized ChangeHistoryDetailData object including a link toChangeHistoryData
that has been logged withlog(ChangeHistoryData)
-
createHqlQuery
public <R> org.hibernate.query.Query<R> createHqlQuery(String hql, Class<R> returnType)
Creates a Hibernate HQL query with a known return type. Use this to get information from the database that is relevent for the logging implementation. The query uses the stateless session, which means that there is no first- or second-level cache and on support for initialization of proxies. We recommend that queries are used to return scalar values only, not entities.- Returns:
- A Query
- Since:
- 3.12
-
flush
public void flush()
Flushes any batched changes to the database.
-
createSqlQuery
@Deprecated public org.hibernate.query.Query<?> createSqlQuery(String sql)
Deprecated.In 3.12. usecreateSqlQuery(String, Class)
insteadCreates a Hibernate SQL query. Use this to get information from the database that is relevent for the logging implementation. The query uses the stateless session.- Returns:
- A query
-
createSqlQuery
public <R> org.hibernate.query.Query<R> createSqlQuery(String sql, Class<R> returnType)
Creates a Hibernate SQL query with a known return type. Use this to get information from the database that is relevent for the logging implementation. The query uses the stateless session.- Returns:
- A query
- Since:
- 3.12
-
getSession
private org.hibernate.StatelessSession getSession()
-
-