Question

I`m using the play framework (scala) with hibernate 4 (orm).

I created some models.. here my example model:

@Entity
@Table(name="aModel")  
class AModel {  

  @Id
  @GeneratedValue
  var id:Long = 0

  @OneToOne
  var contact:Contact = null

}

My DAO is inside the same file as my AModel class:

object AModel extends GenericDao(classOf[AModel]){
    def getAllModels():List[AModel] = {
      tx.begin
      val query = entityManager.createQuery("FROM " + classOf[AModel].getName)
      val result = query.getResultList.asInstanceOf[List[AModel]]
      tx.commit
      return result
    }
}

In my persistence.xml I map the AModel class as follows:

<persistence-unit name="HibernateService">
    <description>
        Persistence unit
    </description>
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <class>models.AModel</class>
    <properties>
      <!-- all properties -->
    </properties>
</persistence-unit>

Still it sais that it cant find any suitable mapping. What am I doing wrong?

Here the output:

no persistent classes found for query class: FROM models.AModel$

I hope there is somebody able to help me. Thanks in advance..

Pas de solution correcte

Autres conseils

I found the error for this concrete issue. I used the objects (DAO) class name within the query. The solution was to switch to the class AModel! (Not the Object AModel)

No I have another issue..

I receive a hibernate.QueryException: could not resolve property: type of: models.AModel

Does anyone know anything about this exact error message?

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top