I have project in PLAY FRAMEWORK wich contain few submodules.
Each submodule has folder structure like this:
I figure it out on my own.
Runtime error:
[IllegalArgumentException: Unknown entity: models.common.AppMode] Is caused by Jpa/Hibernate configuration. Problem is that Jpa/Hibernate sees my entities (mark by annotation @Entity) while compilation, but in runtime dosn't. To fix that I've to manually point all my models class (entitites) in persistance.xml file as follow:
/conf/META-INF/persistence.xml
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="defaultPersistenceUnit" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<non-jta-data-source>DefaultDS</non-jta-data-source>
<class>models.common.AppMode</class>
<class>models.Customer</class>
<class>models.Complaint</class>
<properties>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
<property name="hibernate.show_sql" value="true"/>
</properties>
</persistence-unit>
</persistence>
Original post: package names (namespaces) in subproject classes in Play Framework
I wonder why in main project (f.e: /app/models/User.java
) I can use annotation @javax.persistence.Entity
(and it works), but in sub project (f.e: /modules/common/app/models/AppMode.java
) it dosnt work, the annotation @javax.persistence.Entity
is not enought, I have to point each model class in persistance.xml file.
I think it is a bug in playframework (I've checked 2.2.1, 2.2.4, and 2.3.4 versions)