문제

I defined a base Model which doesn't has fields, and enhance it by Ebean's eclipse plugin. Then I use a java decompiler to decompile it, found ebean has add some fields and methods to it:

private static String _EBEAN_MARKER = "play.modules.ebean.Model";

protected EntityBeanIntercept _ebean_intercept = new EntityBeanIntercept(this);

protected transient Object _ebean_identity;

public String _ebean_getMarker() {
    return _EBEAN_MARKER;
}

public EntityBeanIntercept _ebean_getIntercept() {
    return this._ebean_intercept;
}

public EntityBeanIntercept _ebean_intercept() {
    if (this._ebean_intercept == null)
        this._ebean_intercept = new EntityBeanIntercept(this);
    return this._ebean_intercept;
}

public void addPropertyChangeListener(PropertyChangeListener listener) {
    this._ebean_intercept.addPropertyChangeListener(listener);
}

public void addPropertyChangeListener(String name, PropertyChangeListener listener) {
    this._ebean_intercept.addPropertyChangeListener(name, listener);
}

public void removePropertyChangeListener(PropertyChangeListener listener) {
    this._ebean_intercept.removePropertyChangeListener(listener);
}

public void removePropertyChangeListener(String name, PropertyChangeListener listener) {
    this._ebean_intercept.removePropertyChangeListener(name, listener);
}

public void _ebean_setEmbeddedLoaded() {}

public boolean _ebean_isEmbeddedNewOrDirty() {
    return false;
}

public Object _ebean_newInstance() {
    return new Model();
}

Then I copied these code to the original Model class, disabled the Ebean's enhancer, compile it by eclipse.

I thought it should have the same effect as enhancing by Ebean.

Then I packaged it as a jar, put it in my project, defined a model class Article to extend it.

But there is an error:

An unexpected error occured caused by exception PersistenceException:
java.lang.IllegalStateException: Class [class test.Model] is not enhanced 
  and [class models.Article] is - (you can not mix!!)

It seems Ebean not treat my new Model class as enhanced. I wonder how Ebean check if a class has been enhanced by it or not?

도움이 되었습니까?

해결책

Ebean adds enhancements to your models.Article class too - basically for every property/getter/setter.

create this hierarchy again (without adding stuff to Model) and inspect the resulting code of both objects.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top