How to get rid of 'java.lang.IllegalArgumentException: Unknown entity' while running a simple hibernate app?

前端 未结 3 1073
天命终不由人
天命终不由人 2021-01-04 18:48

I am new to Hibernate. While creating a small app using it I got following exception:

Exception in thread \"main\" java.lang.IllegalArgumentException: Unknown entit

3条回答
  •  离开以前
    2021-01-04 19:05

    Depends bit about project structure, but likely by adding following to persistence.xml directly under persistence-unit element.

    model.Students
    model.Address
    

    Exactly like this:

    
    
      
        org.hibernate.ejb.HibernatePersistence
    
        students
        model.Students
        model.Address
        false
        
          
          
          
          
          
        
      
    
    

    By the way, why do you configure properties like hibernate.dialect in both persistence.xml and hibernate.cfg.xml?

提交回复
热议问题