Hibernate problem - “Use of @OneToMany or @ManyToMany targeting an unmapped class”

前端 未结 7 865
梦谈多话
梦谈多话 2020-11-28 04:52

I\'m finding my feet with Hibernate Annotations and I\'ve hit a problem I hope someone can help with.

I have 2 entities, Section and ScopeTopic. The section has a Li

7条回答
  •  迷失自我
    2020-11-28 05:08

    In my case a has to add my classes, when building the SessionFactory, with addAnnotationClass

    Configuration configuration.configure();
    StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties());
    SessionFactory sessionFactory = configuration
                .addAnnotatedClass(MyEntity1.class)
                .addAnnotatedClass(MyEntity2.class)
                .buildSessionFactory(builder.build());
    

提交回复
热议问题