| |

VerySource

 Forgot password?
 Register
Search
View: 785|Reply: 3

Hibernate Dialect must be explicitly set exception

[Copy link]

1

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-21 19:40:01
| Show all posts |Read mode
My configuration file is like this
<? xml version = '1.0' encoding = 'UTF-8'?>
<! DOCTYPE hibernate-configuration PUBLIC
"-// Hibernate / Hibernate Configuration DTD 3.0 // EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">


<hibernate-configuration>

  <session-factory>
    <property name = "hibernate.connection.username"> sa </ property>
    <property name = "hibernate.connection.url"> jdbc: microsoft: sqlserver: // localhost: 1433: pethospital </ property>
    <property name = "hibernate.dialect"> org.hibernate.dialect.SQLServerDialect </ property>
    <property name = "hibernate.connection.driver_class"> com.microsoft.jdbc.sqlserver.SQLServerDriver </ property>

    <mapping resource = "pethospital / Host / hibernate / bean / HostInfo.hbm.xml"> </ mapping>
    <mapping resource = "pethospital / Host / hibernate / bean / PetInfo.hbm.xml"> </ mapping>
  </ session-factory>

</ hibernate-configuration>

The exception is this
org.hibernate.HibernateException: Hibernate Dialect must be explicitly set

at org.hibernate.dialect.DialectFactory.determineDialect (DialectFactory.java:57)

at org.hibernate.dialect.DialectFactory.buildDialect (DialectFactory.java:39)

at org.hibernate.cfg.SettingsFactory.determineDialect (SettingsFactory.java:378)

at org.hibernate.cfg.SettingsFactory.buildSettings (SettingsFactory.java:110)

at org.hibernate.cfg.Configuration.buildSettings (Configuration.java:1881)

at org.hibernate.cfg.Configuration.buildSessionFactory (Configuration.java:1174)

at pethospital.Host.hibernate.HibernateDAO. <clinit> (HibernateDAO.java:16)
How to solve
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-2-13 10:15:01
| Show all posts
It is possible that your hibernate configuration file cannot find your mapping file
<mapping resource = "pethospital / Host / hibernate / bean / PetInfo.hbm.xml"> </ mapping>
Note this sentence, your package path
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-30 08:45:01
| Show all posts
Correct way of writing: public void save(Login login) {
To
To
Configuration config = new Configuration();
[color=#FF0000]SessionFactory sf=config.configure().buildSessionFactory();[/color] Session s=sf.openSession();
Transaction t =s.beginTransaction();
s.save(login);
t.commit();
s.close();
To
}
}
Wrong wording: public void save(Login login) {
To
To
Configuration config = new Configuration();
[color=#0000FF]SessionFactory sf=config.buildSessionFactory();[/color] Session s=sf.openSession();
Transaction t =s.beginTransaction();
s.save(login);
t.commit();
s.close();
To
}
}
Please refer to my blog for specific error reasons:
http://www.cnblogs.com/moonandsun/archive/2008/06/07/1215818.html
Hope it helps you.
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-9-1 16:00:01
| Show all posts
[Quote=Quote the reply fromxixi8558on the 2nd floor:]
Correct way of writing: public void save(Login login) {


Configuration config = new Configuration();
SessionFactory sf=config.configure().buildSessionFactory(); Session s=sf.openSession();
Transaction t =s.beginTransaction();
s.save(login);
t.commit();
s.close();

}
}
Wrong wording: public void save(Login login) {


Configuration config = new Configuration();
SessionFactory sf=config.…
[/Quote]

Positive solution, support.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list