mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#993 - ENH: Add flush() to EbeanServer and Model to make it more accessible than the current transaction.flushBatch()
This commit is contained in:
@@ -613,6 +613,19 @@ public interface EbeanServer {
|
||||
*/
|
||||
Transaction currentTransaction();
|
||||
|
||||
/**
|
||||
* Flush the JDBC batch on the current transaction.
|
||||
* <p>
|
||||
* This only is useful when JDBC batch is used. Flush occurs automatically when the
|
||||
* transaction commits or batch size is reached. This manually flushes the JDBC batch
|
||||
* buffer.
|
||||
* </p>
|
||||
* <p>
|
||||
* This is the same as <code>currentTransaction().flush()</code>.
|
||||
* </p>
|
||||
*/
|
||||
void flush();
|
||||
|
||||
/**
|
||||
* Commit the current transaction.
|
||||
*/
|
||||
|
||||
@@ -190,6 +190,17 @@ public abstract class Model {
|
||||
db().save(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush any batched changes to the database.
|
||||
* <p>
|
||||
* When using JDBC batch flushing occurs automatically at commit() time or when the batch size
|
||||
* is reached. This provides the ability to manually flush the batch.
|
||||
* </p>
|
||||
*/
|
||||
public void flush() {
|
||||
db().flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update this entity.
|
||||
*
|
||||
|
||||
@@ -429,6 +429,14 @@ public interface Transaction extends AutoCloseable {
|
||||
* <li>Transaction commit occurs</li>
|
||||
* </ul>
|
||||
*/
|
||||
void flush() throws PersistenceException;
|
||||
|
||||
/**
|
||||
* This is a synonym for flush() and will be deprecated.
|
||||
* <p>
|
||||
* flush() is preferred as it matches the JPA flush() method.
|
||||
* </p>
|
||||
*/
|
||||
void flushBatch() throws PersistenceException;
|
||||
|
||||
/**
|
||||
|
||||
@@ -295,9 +295,14 @@ public class ScopedTransaction implements SpiTransaction {
|
||||
return transaction.isBatchFlushOnQuery();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() throws PersistenceException {
|
||||
transaction.flush();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flushBatch() throws PersistenceException {
|
||||
transaction.flushBatch();
|
||||
flush();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -840,6 +840,11 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
return transactionScopeManager.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() {
|
||||
currentTransaction().flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* Commit the current transaction.
|
||||
*/
|
||||
|
||||
@@ -731,13 +731,18 @@ public class JdbcTransaction implements SpiTransaction {
|
||||
* </p>
|
||||
*/
|
||||
@Override
|
||||
public void flushBatch() {
|
||||
public void flush() {
|
||||
if (!isActive()) {
|
||||
throw new IllegalStateException(illegalStateMessage);
|
||||
}
|
||||
internalBatchFlush();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flushBatch() {
|
||||
flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush the JDBC batch and execute derived relationship statements if necessary.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user