Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experimental Feature - Freeze and detach beans (and attach) #3317

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ebean-api/src/main/java/io/ebean/ModifyAwareType.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,9 @@ public interface ModifyAwareType {
*/
void setMarkedDirty(boolean markedDirty);

/**
* Return a unmodifiable version of this type.
*/
Object freeze();

}
19 changes: 19 additions & 0 deletions ebean-api/src/main/java/io/ebean/Transaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import io.ebean.annotation.DocStoreMode;
import io.ebean.annotation.PersistBatch;
import io.ebean.bean.FrozenBeans;
import io.ebean.config.DatabaseConfig;
import io.ebean.config.DocStoreConfig;

Expand Down Expand Up @@ -54,6 +55,24 @@ static Transaction current() {
*/
int SERIALIZABLE = java.sql.Connection.TRANSACTION_SERIALIZABLE;


/**
* Experimental Feature - Freeze the beans in the persistence context and detach them.
*/
@Deprecated(since = "Experimental Feature")
default FrozenBeans freezeAndDetach() {
throw new UnsupportedOperationException();
}

/**
* Experimental Feature - Attach frozen beans to the persistence context so that they can be
* used with ORM queries (with the persistence context acting like a cache).
*/
@Deprecated(since = "Experimental Feature")
default void attach(FrozenBeans frozenBeans) {
throw new UnsupportedOperationException();
}

/**
* Register a TransactionCallback with this transaction.
*/
Expand Down
5 changes: 5 additions & 0 deletions ebean-api/src/main/java/io/ebean/bean/BeanCollection.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ enum ModifyListenMode {
ALL
}

/**
* Return a unmodifiable collection of the underlying entities.
*/
Object freeze();

/**
* Set the disableLazyLoad state.
*/
Expand Down
12 changes: 12 additions & 0 deletions ebean-api/src/main/java/io/ebean/bean/EntityBeanIntercept.java
Original file line number Diff line number Diff line change
Expand Up @@ -552,4 +552,16 @@ public interface EntityBeanIntercept extends Serializable {
* Update the 'next' mutable info returning the content that was obtained via dirty detection.
*/
String mutableNext(int propertyIndex);

/**
* Set that lazy loading if invoked throws a PersistenceException.
*/
void errorOnLazyLoad(boolean lazyLoadAsError);

/**
* Freeze the intercept so that it is readOnly.
* Lazy loading and mutation of the bean is not allowed.
*/
void freeze();

}
9 changes: 9 additions & 0 deletions ebean-api/src/main/java/io/ebean/bean/FrozenBeans.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package io.ebean.bean;

import java.io.Serializable;

/**
* Holds entity beans that are frozen.
*/
public interface FrozenBeans extends Serializable {
}
Loading
Loading