public class TransactionHibernate extends Object implements ITransactionHibernate, ITransactionSPI
Constructor and Description |
---|
TransactionHibernate()
Creates a new transaction object.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addObserver(ITransactionObserver observer)
Adds an observer for this transaction.
|
void |
begin() |
void |
close()
Closes this transaction, rolling back any changes not committed by a previous call to
ITransaction.commit() , and
removes any association of this transaction from the current thread. |
void |
commit() |
void |
dispose() |
protected void |
finalize() |
Object |
getAttribute(String name)
Returns the value of the named attribute, or
null if no
attribute of the given name exists. |
long |
getBeginTimeMillis()
Returns the time when this transaction began in milliseconds since January 1, 1970 UTC.
|
ITransaction |
getByConnectionId(String id)
Returns an
ITransaction that represents the same transaction but
that returns the connection with the given id as default. |
Connection |
getConnection()
Returns the default jdbc connection for this transaction.
|
Connection |
getConnection(String databaseId)
Returns the jdbc connection associated with the specified id.
|
long |
getCreationTimeMillis()
Returns the time this transaction object was created.
|
EntityManager |
getEntityManager()
Returns the default entity manager for this transaction.
|
EntityManager |
getEntityManager(String databaseId)
Returns the entity manager associated with the specified database.
|
org.hibernate.Session |
getSession()
Returns the default hibernate session for this transaction.
|
org.hibernate.Session |
getSession(String databaseId)
Returns the hibernate session associated with the specified database.
|
Throwable |
getTransactionCreationTrace()
Returns a throwable used just as a trace to the transaction creation.
|
boolean |
isActive()
Returns true if the transaction is currently active, false otherwise.
|
void |
removeAttribute(String name)
Removes an attribute from this transaction.
|
boolean |
removeObserver(ITransactionObserver observer)
Removes an observer for this transaction.
|
void |
rollback() |
void |
setAttribute(String name,
Object value)
Stores an attribute in this transaction.
|
void |
setTransactionProviderCallback(ITransactionProviderCallback callback)
Sets the transaction provider callback object to be used by this
transaction.
|
public TransactionHibernate()
PortalTransactionFactory
instead.PortalTransactionFactory.createTransaction()
public EntityManager getEntityManager()
ITransactionJPA
getEntityManager
in interface ITransactionJPA
public EntityManager getEntityManager(String databaseId)
ITransactionJPA
getEntityManager
in interface ITransactionJPA
databaseId
- the database id.public org.hibernate.Session getSession() throws DaoException
ITransactionHibernate
getSession
in interface ITransactionHibernate
DaoException
public org.hibernate.Session getSession(String databaseId) throws DaoException
ITransactionHibernate
getSession
in interface ITransactionHibernate
databaseId
- the database id.DaoException
public void dispose() throws DaoException
dispose
in interface ITransaction
DaoException
public void close()
ITransaction
ITransaction.commit()
, and
removes any association of this transaction from the current thread.close
in interface Closeable
close
in interface AutoCloseable
close
in interface ITransaction
protected void finalize() throws Throwable
public boolean isActive()
ITransaction
isActive
in interface ITransaction
public void begin() throws DaoException
begin
in interface ITransaction
DaoException
public void commit() throws DaoException
commit
in interface ITransaction
DaoException
public void rollback() throws DaoException
rollback
in interface ITransaction
DaoException
public Connection getConnection() throws DaoException
ITransactionJdbc
getConnection
in interface ITransactionJdbc
DaoException
public Connection getConnection(String databaseId) throws DaoException
ITransactionJdbc
getConnection
in interface ITransactionJdbc
databaseId
- the connection id.DaoException
public ITransaction getByConnectionId(String id) throws DaoException
ITransaction
ITransaction
that represents the same transaction but
that returns the connection with the given id as default. How the id
represents the connection is defined by the concrete class that
implements this interface.getByConnectionId
in interface ITransaction
id
- the connection id.DaoException
public boolean addObserver(ITransactionObserver observer) throws PortalException
ITransaction
addObserver
in interface ITransaction
observer
- the observer.PortalException
public boolean removeObserver(ITransactionObserver observer) throws PortalException
ITransaction
removeObserver
in interface ITransaction
observer
- the observer.PortalException
public long getBeginTimeMillis()
ITransactionSPI
getBeginTimeMillis
in interface ITransactionSPI
public Object getAttribute(String name)
ITransaction
null
if no
attribute of the given name exists.
Different transaction instances that refer to the same transaction
(see ITransaction.getByConnectionId(String)
) share the same attributes.
getAttribute
in interface ITransaction
name
- the name of the attribute.public void setAttribute(String name, Object value)
ITransaction
null
, the effect is the same as calling
ITransaction.removeAttribute(String)
.setAttribute
in interface ITransaction
name
- the name of the attribute.value
- the value to be stored.public void removeAttribute(String name)
ITransaction
removeAttribute
in interface ITransaction
name
- the name of the attribute.public void setTransactionProviderCallback(ITransactionProviderCallback callback)
ITransactionSPI
setTransactionProviderCallback
in interface ITransactionSPI
callback
- the callback object.public Throwable getTransactionCreationTrace()
ITransactionSPI
StackTraceElement
, using
a throwable also provides higher-level methods.getTransactionCreationTrace
in interface ITransactionSPI
Throwable.getStackTrace()
public long getCreationTimeMillis()
ITransactionSPI
getCreationTimeMillis
in interface ITransactionSPI
LumisXP 12.5.0.200928 - Copyright © 2006–2020 Lumis EIP Tecnologia da Informação LTDA. All Rights Reserved.