How to fix Unknown Entity Error on Dropwizard

  • Posted on: 7 September 2015
  • By: robin
Dropwizard Logo

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) {...}