org.hibernate.MappingException: Unknown entity: annotations.Users

前端 未结 19 1580
情歌与酒
情歌与酒 2020-12-01 07:11

Consider the hierarchy :

\"enter

And the following classes and xml :

19条回答
  •  北海茫月
    2020-12-01 08:06

     public static void main(String[] args) {
          try{
            // factory = new Configuration().configure().buildSessionFactory();
             factory = new AnnotationConfiguration().
                       configure().
                       //addPackage("com.xyz") //add package if used.
                       addAnnotatedClass(Employee.class).
                       buildSessionFactory();
          }catch (Throwable ex) { 
             System.err.println("Failed to create sessionFactory object." + ex);
             throw new ExceptionInInitializerError(ex); 
          }//you can write like this in your test class inside main method.this way you will be able to do the things using annotaions only
    

提交回复
热议问题