How to persist models entity in playframework submodule using jpa/hibernate

前端 未结 1 562
予麋鹿
予麋鹿 2021-01-17 07:14

I have project in PLAY FRAMEWORK wich contain few submodules.

Each submodule has folder structure like this:

  • app:
    • controllers
1条回答
  •  清酒与你
    2021-01-17 07:28

    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

    
    
        
            org.hibernate.ejb.HibernatePersistence
            DefaultDS
                models.common.AppMode
                models.Customer
                models.Complaint
            
                
                
                
            
        
    
    

    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)

    0 讨论(0)
提交回复
热议问题