How to fix Unknown Entity Error on Dropwizard

A common beginner Error is: 

org.hibernate.MappingException: Unknown entity: my.package.core.MyClass

First make sure that your class has

@Table(name = "demo")

Now check you Application class and go to the point where you create your Hibernate object.

private final HibernateBundle<AuthDemoConfig> hibernateBundle = 
new HibernateBundle<DemoConfig>(MyClass.class) {

    public DataSourceFactory getDataSourceFactory(
            AuthDemoConfig configuration) {
        return configuration.getDataSourceFactory();


The problem appears when an entity is used that was not registered to Hibernate. To register you class add it to the parameters of your HibernateBundle initialisation. For Multiple classes it can look like this:

new HibernateBundle<DemoConfig>(MyClass.class, MyClass2.class) {...}

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.

This site uses Akismet to reduce spam. Learn how your comment data is processed.