[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] Savepoints, Checkpoints, Rollbacks?
|
OK so it doesn't look like this is possible directly with JPA or Eclipselink
as far as I can tell however I've managed to coble this together, in case
its of any use to anyone hear goes....
first to get a savepoint...
public Savepoint getSavepoint() throws SQLException {
flush();
//Get the SQL connection
Connection conn = ((UnitOfWorkImpl) ((JpaEntityManager)
em).getActiveSession().acquireUnitOfWork()).getAccessor().getConnection();
//Get a savepoint from the SQL connection
return conn.setSavepoint();
}
next to make use of it...
public void commitToSave1(Savepoint sp) throws SQLException {
Connection conn = ((UnitOfWorkImpl) ((JpaEntityManager)
em).getActiveSession().acquireUnitOfWork()).getAccessor().getConnection();
//roll the connection back to the savepoint
conn.rollback(sp);
//commit the current state of the transaction
conn.commit();
//clear the persistence context causing all managed entities to
//become detached
clear();
//commit the transaction to release locks and reset the entity
//manager
getTransaction().commit();
}
Hope that may be of use to someone:-D
paulccarey wrote:
>
> Hi I am using eclipselink with JPA
>
> Is it possible to create savepoints like JDBC can?
>
> So I can rollback a transaction to a certain point without losing all
> changes?
>
> Thanks
>
> P
>
--
View this message in context: http://www.nabble.com/Savepoints%2C-Checkpoints%2C-Rollbacks--tp21980310p21986584.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.