I have project in PLAY FRAMEWORK wich contain few submodules.
Each submodule has folder structure like this:
- app:
- controllers
- models
- views
- conf:
- submodulename.routes
- build.sbt
I would like to persist all java class entities in folder: models.
How should I configure play framework and/or hibernate entity manager to scan this folders for entities.
I have example model class as follow:
package models.common;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.NoResultException;
import controllers.common.Index;
import play.data.validation.Constraints;
import play.db.jpa.JPA;
@Entity
public class AppMode {
public static AppMode getCurrentConfigurationEntry() {
return JPA.em().find(AppMode.class, 1L);
}
//rest of code here- not important//
}
but in this state jvm return me a runtime error:
[IllegalArgumentException: Unknown entity: models.common.AppMode]
NOTE : I'm using play 2.2.1
I've noticed that hibernate is correctly create sql structure for AppMode entity when I set this in persistance.xml:
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
But when I go further I am getting next error:
[IllegalArgumentException: org.hibernate.hql.ast.QuerySyntaxException: MIncident is not mapped
While I have annotation @Entity on that class.
It seems to be correct mapped, but I cant do any operation like hsql select
or JPA.em().find()
on that entities