1

I try to generate database schema according to:
https://stackoverflow.com/a/17844417/9608756

but eclipse doesn't recognize class EnversSchemaGenerator. There is no automatic import for this class and can't see it in my jars.

This is script:

Configuration config = new Configuration();
        config.setProperty("hibernate.dialect","org.hibernate.dialect.H2Dialect");

config.addAnnotatedClass(MyClass.class);

SchemaExport export = new EnversSchemaGenerator(config).export(); // ERROR!

This is pom.xml:

<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-core</artifactId>
    <version>5.4.3.Final</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-entitymanager -->
<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-entitymanager</artifactId>
    <version>5.4.3.Final</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-envers -->
<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-envers</artifactId>
    <version>5.4.3.Final</version>
</dependency>

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-orm</artifactId>
    <version>4.1.6.RELEASE</version>
</dependency>
stakowerflol
  • 979
  • 1
  • 11
  • 20

1 Answers1

2

The sample you're trying to use is based on an older version of the Hibernate. The EnversSchemaGenerator class has been removed from Hibernate source (issue HHH-11461).

You can use the SchemaExport class as mentioned in Programmatically Generating Database Schema with Hibernate 5.

zaerymoghaddam
  • 3,037
  • 1
  • 27
  • 33