我正在使用 Play!Framwork 1.2.5。
我正在尝试在我的项目中为模型中的案例实施 CRUD。我按照此处描述的步骤操作,但出现以下错误:
Model models.Media is not managed by any plugin
at play.db.Model$Manager.factoryFor(Model.java:57)
at controllers.CRUD$ObjectType.<init>(CRUD.java:215)
at controllers.CRUD$ObjectType.get(CRUD.java:238)
at controllers.CRUD$ObjectType$get.call(Unknown Source)
at {module:crud}/app/views/tags/crud/types.tag.(line:4)
at play.templates.GroovyTemplate.internalRender(GroovyTemplate.java:247)
at play.templates.GroovyTemplate$ExecutableTemplate.invokeTag(GroovyTemplate.java:401)
at {module:crud}/conf/routes.(line:4)
at play.templates.GroovyTemplate.internalRender(GroovyTemplate.java:247)
at play.templates.Template.render(Template.java:26)
at play.templates.GroovyTemplate.render(GroovyTemplate.java:202)
at play.mvc.Router.parse(Router.java:162)
at play.mvc.Router.parse(Router.java:190)
at play.mvc.Router.parse(Router.java:164)
at play.mvc.Router.load(Router.java:48)
at play.mvc.Router.detectChanges(Router.java:219)
at Invocation.HTTP Request(Play!)
这是类媒体的代码:
import org.hibernate.annotations.Entity;
import org.hibernate.annotations.GenericGenerator;
import play.db.jpa.Model;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToOne;
@Entity
public class Media extends Model{
@Id
private String uuid;
@OneToOne
private Video video;
@OneToOne
private Picture picture;
public String getUuid() {
return uuid;
}
public void setUuid(String id) {
this.uuid = id;
}
public Video getVideo() {
return video;
}
public void setVideo(Video video) {
this.video = video;
}
public Picture getPicture() {
return picture;
}
public void setPicture(Picture picture) {
this.picture = picture;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof Media))
return false;
Media media = (Media) obj;
return media.getUuid().equals(this.uuid);
}
}