mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-09-25 03:31:07 +00:00
Although this is ok, makes me think that another option is just to have query.setReadOnly(true) to mean ... readOnly + disableLazyLoad + error reading unloaded property or collection. As in, readOnly true without these extra things does not that good [as in the existing readOnly does not seem very good/safe/useful to use].
71 lines
1.4 KiB
Java
71 lines
1.4 KiB
Java
package io.ebean.bean;
|
|
|
|
/**
|
|
* Common base features for EntityBeanIntercept.
|
|
*/
|
|
abstract class InterceptBase implements EntityBeanIntercept {
|
|
|
|
final EntityBean owner;
|
|
boolean fullyLoadedBean;
|
|
|
|
/**
|
|
* Create with a given entity.
|
|
*/
|
|
InterceptBase(Object ownerBean) {
|
|
this.owner = (EntityBean) ownerBean;
|
|
}
|
|
|
|
/**
|
|
* EXPERIMENTAL - Constructor only for use by serialization frameworks.
|
|
*/
|
|
InterceptBase() {
|
|
this.owner = null;
|
|
}
|
|
|
|
@Override
|
|
public final EntityBean owner() {
|
|
return owner;
|
|
}
|
|
|
|
@Override
|
|
public final boolean isFullyLoadedBean() {
|
|
return fullyLoadedBean;
|
|
}
|
|
|
|
@Override
|
|
public final void setFullyLoadedBean(boolean fullyLoadedBean) {
|
|
this.fullyLoadedBean = fullyLoadedBean;
|
|
}
|
|
|
|
@Override
|
|
public final String property(int propertyIndex) {
|
|
if (propertyIndex == -1) {
|
|
return null;
|
|
}
|
|
return owner._ebean_getPropertyName(propertyIndex);
|
|
}
|
|
|
|
@Override
|
|
public final int findProperty(String propertyName) {
|
|
final String[] names = owner._ebean_getPropertyNames();
|
|
for (int i = 0; i < names.length; i++) {
|
|
if (names[i].equals(propertyName)) {
|
|
return i;
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
@Override
|
|
public final StringBuilder loadedPropertyKey() {
|
|
final StringBuilder sb = new StringBuilder();
|
|
final int len = propertyLength();
|
|
for (int i = 0; i < len; i++) {
|
|
if (isLoadedProperty(i)) {
|
|
sb.append(i).append(',');
|
|
}
|
|
}
|
|
return sb;
|
|
}
|
|
}
|