Exception in thread "main" org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.determineDialect(DialectFactoryImpl.java:104)
at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:71)
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:209)
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:111)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:234)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:206)
at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1885)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1843)
at com.ranga.MultiTenancyDemo.main(MultiTenancyDemo.java:34)
Problem:
// Create the SessionFactory from hibernate.cfg.xml
Configuration configuration = new Configuration();
System.out.println("Hibernate Configuration loaded.");
//apply configuration property settings to StandardServiceRegistryBuilder
serviceRegistry = new StandardServiceRegistryBuilder().applySettings(
configuration.getProperties()).build();
System.out.println("Hibernate serviceRegistry created.");
sessionFactory = configuration.buildSessionFactory(serviceRegistry);
System.out.println("Hibernate sessionFactory object created.");
Solution:
After creation of Configuration object, we need to call the configuration.configure("hibernate.cfg.xml"); method.
at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.determineDialect(DialectFactoryImpl.java:104)
at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:71)
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:209)
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:111)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:234)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:206)
at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1885)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1843)
at com.ranga.MultiTenancyDemo.main(MultiTenancyDemo.java:34)
Problem:
// Create the SessionFactory from hibernate.cfg.xml
Configuration configuration = new Configuration();
System.out.println("Hibernate Configuration loaded.");
//apply configuration property settings to StandardServiceRegistryBuilder
serviceRegistry = new StandardServiceRegistryBuilder().applySettings(
configuration.getProperties()).build();
System.out.println("Hibernate serviceRegistry created.");
sessionFactory = configuration.buildSessionFactory(serviceRegistry);
System.out.println("Hibernate sessionFactory object created.");
Solution:
After creation of Configuration object, we need to call the configuration.configure("hibernate.cfg.xml"); method.
0 comments:
Post a Comment