sim51/logisima-play-neo4j — Issue #8: Add Base Model class to which all other models extend
Author: jph303
Created: 2012-01-24 13:10:32+00:00
State: open

I am trying to add a base model class which all my other models will extend to provide some basic audit information. As soon as I have my models extend anything other than Neo4jModel directly I get the following error:

An unexpected error occured caused by exception UnexpectedException: Error in PropertiesEnhancer

play.exceptions.UnexpectedException: While applying play.modules.neo4j.Neo4jPlugin@196dc99 on models.Post
at play.plugins.PluginCollection.enhance(PluginCollection.java:511)
at play.classloading.ApplicationClasses$ApplicationClass.enhance(ApplicationClasses.java:235)
at play.classloading.ApplicationClassloader.loadApplicationClass(ApplicationClassloader.java:165)
at play.classloading.ApplicationClassloader.getAllClasses(ApplicationClassloader.java:429)
at play.Play.start(Play.java:505)
at play.Play.detectChanges(Play.java:618)
at play.Invoker$Invocation.init(Invoker.java:198)
at Invocation.HTTP Request(Play!)
Caused by: play.exceptions.UnexpectedException: Error in PropertiesEnhancer
at play.modules.neo4j.model.Neo4jModelEnhancer.enhanceThisClass(Neo4jModelEnhancer.java:82)
at play.modules.neo4j.Neo4jPlugin.enhance(Neo4jPlugin.java:65)
at play.plugins.PluginCollection.enhance(PluginCollection.java:506)
... 7 more
Caused by: javassist.CannotCompileException: [source error] no such a constructor
at javassist.CtNewConstructor.make(CtNewConstructor.java:76)
at play.modules.neo4j.model.Neo4jModelEnhancer.enhanceThisClass(Neo4jModelEnhancer.java:76)
... 9 more
Caused by: compile error: no such a constructor
at javassist.compiler.MemberCodeGen.atMethodCallCore2(MemberCodeGen.java:593)
at javassist.compiler.MemberCodeGen.atMethodCallCore(MemberCodeGen.java:575)
at javassist.compiler.MemberCodeGen.atCallExpr(MemberCodeGen.java:523)
at javassist.compiler.JvstCodeGen.atCallExpr(JvstCodeGen.java:243)
at javassist.compiler.ast.CallExpr.accept(CallExpr.java:45)
at javassist.compiler.CodeGen.atStmnt(CodeGen.java:337)
at javassist.compiler.ast.Stmnt.accept(Stmnt.java:49)
at javassist.compiler.CodeGen.atStmnt(CodeGen.java:350)
at javassist.compiler.ast.Stmnt.accept(Stmnt.java:49)
at javassist.compiler.CodeGen.atMethodBody(CodeGen.java:291)
at javassist.compiler.CodeGen.atMethodDecl(CodeGen.java:273)
at javassist.compiler.ast.MethodDecl.accept(MethodDecl.java:43)
at javassist.compiler.Javac.compileMethod(Javac.java:154)
at javassist.compiler.Javac.compile(Javac.java:94)
at javassist.CtNewConstructor.make(CtNewConstructor.java:69)

Is there anyway around this, I would really like to avoid overwriting the save method and applying the same audit properties to all my model classes?

Here is simplistic example of my base model class:

public class BaseModel extends Neo4jModel{

public long creationDate;
public long modifiedDate;
public String status;

@Override
public T save() throws Neo4jException {
ModelManager modelManager = (ModelManager) Spring.getBean(ModelManager.NAME);

if(this.node == null)
{
this.creationDate = modelManager.getCurrentTimeStamp();
this.status = TandemConstants.VALUE_STATUS_ACTIVE;
}
this.modifiedDate = modelManager.getCurrentTimeStamp();
return super.save();
}
}