1

I am developing a java web application with Hibernate for database connectivity, before this application I was using Hibernate 4.3.x and uses the following code for automatic creation of database tables

public class TableCreator {

public static void main(String[] args) {
    try {
        Configuration cfg = new Configuration();
        cfg.addAnnotatedClass(AdminMaster.class);
        cfg.addAnnotatedClass(CorporateMaster.class);
        cfg.addAnnotatedClass(Customer.class);
        cfg.addAnnotatedClass(LoginMaster.class);
        cfg.addAnnotatedClass(Notifications.class);

        cfg.configure();
        SchemaExport se = new SchemaExport(cfg);
        se.create(true, true);
        System.out.println("Table Created!!!");
    } catch (Exception ex) {
        ex.printStackTrace();
    }

}
}

Now when I try to use the same code with Hibernate 5.2 following lines are shown in red in Netbeans

SchemaExport se = new SchemaExport(cfg);
se.create(true, true);

and the error shown is :

Schemaexport Class in Schemaexport cannot be applied to given types;
required : no arguments
found :configuration

I totally don't know what to do now, please help me guys..

Jens
  • 67,715
  • 15
  • 98
  • 113
Deepak Pandey
  • 1,322
  • 12
  • 21
  • which database are you using? – S.B Jun 16 '16 at 10:32
  • Add the complete stacktrace please – Jens Jun 16 '16 at 10:36
  • http://stackoverflow.com/questions/32178041/where-did-configuration-generateschemacreationscript-go-in-hibernate-5 ,this link should help you. – S.B Jun 16 '16 at 10:38
  • Please read my question carefully , I am not saying that I have run the code, I am just saying that the lines are shown in red in Netbeans indicating some error , when I point my mouse on the exclamation mark in the begin of those lines , I see those errors.. – Deepak Pandey Jun 16 '16 at 10:39
  • @DeepakPandey can you Show the Import Statements? – Jens Jun 16 '16 at 10:42
  • import com.houseonholiday.entities.*; import org.hibernate.cfg.Configuration; import org.hibernate.tool.hbm2ddl.SchemaExport; – Deepak Pandey Jun 16 '16 at 10:44

1 Answers1

0

As you can see in the javadoc, the api has changed.

The constructor with Argument configuration does not exists anymore.

Jens
  • 67,715
  • 15
  • 98
  • 113