Hibernate Dialect Setting

本文介绍了在使用Hibernate框架时遇到的HibernateDialect未明确设置的异常及其解决方法。通过正确配置Hibernate,确保dialect被指定,从而避免运行时出现HibernateException。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

错误信息如下:

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:409)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:119)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1933)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1216)
at util.HibernateSessionFactory.<clinit>(HibernateSessionFactory.java:14)
at test.ManyToOneTest.testSave(ManyToOneTest.java:15)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)


解决办法:

/**
 * 在加载核心配置文件时若少写configure(),
 * 则会有hibernate.HibernateException
 * Hibernate Dialect must be explicitly set
 */
//Configuration config = new Configuration();

Configuration config = new Configuration().configure();


sessionFactory = config.buildSessionFactory();


sessionFactory.openSession();


Listening for transport dt_socket at address: 33021 16:36:57.690 [main] INFO com.ulisesbocchio.jasyptspringboot.environment.EnvironmentInitializer -- Initializing Environment: StandardEncryptableEnvironment 16:36:57.829 [main] INFO com.ulisesbocchio.jasyptspringboot.EncryptablePropertySourceConverter -- Converting PropertySource systemProperties [org.springframework.core.env.PropertiesPropertySource] to EncryptableMapPropertySourceWrapper 16:36:57.832 [main] INFO com.ulisesbocchio.jasyptspringboot.EncryptablePropertySourceConverter -- Converting PropertySource systemEnvironment [org.springframework.core.env.SystemEnvironmentPropertySource] to EncryptableSystemEnvironmentPropertySourceWrapper 2025-05-27T16:37:18.998+08:00 INFO 11 --- [auth-center] [ main] [ ] c.hd.cloud.auth.AuthServerApplication : The following 1 profile is active: "redis_default" 2025-05-27T16:37:42.899+08:00 WARN 11 --- [auth-center] [ main] [ ] trationDelegate$BeanPostProcessorChecker : Bean &#39;org.springframework.ws.config.annotation.DelegatingWsConfiguration&#39; of type [org.springframework.ws.config.annotation.DelegatingWsConfiguration$$SpringCGLIB$$0] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). The currently created BeanPostProcessor [annotationActionEndpointMapping] is declared through a non-static factory method on that class; consider declaring it as static instead. 2025-05-27T16:37:45.994+08:00 WARN 11 --- [auth-center] [ main] [ ] trationDelegate$BeanPostProcessorChecker : Bean &#39;org.springframework.cloud.client.loadbalancer.LoadBalancerAutoConfiguration$DeferringLoadBalancerInterceptorConfig&#39; of type [org.springframework.cloud.client.loadbalancer.LoadBalancerAutoConfiguration$DeferringLoadBalancerInterceptorConfig] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). The currently created BeanPostProcessor [lbRestClientPostProcessor] is declared through a non-static factory method on that class; consider declaring it as static instead. 2025-05-27T16:37:46.007+08:00 WARN 11 --- [auth-center] [ main] [ ] trationDelegate$BeanPostProcessorChecker : Bean &#39;deferringLoadBalancerInterceptor&#39; of type [org.springframework.cloud.client.loadbalancer.DeferringLoadBalancerInterceptor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected/applied to a currently created BeanPostProcessor [lbRestClientPostProcessor]? Check the corresponding BeanPostProcessor declaration and its dependencies/advisors. If this bean does not have to be post-processed, declare it with ROLE_INFRASTRUCTURE. 2025-05-27T16:37:46.017+08:00 WARN 11 --- [auth-center] [ main] [ ] trationDelegate$BeanPostProcessorChecker : Bean &#39;org.springframework.cloud.client.loadbalancer.reactive.LoadBalancerBeanPostProcessorAutoConfiguration&#39; of type [org.springframework.cloud.client.loadbalancer.reactive.LoadBalancerBeanPostProcessorAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). The currently created BeanPostProcessor [loadBalancerWebClientBuilderBeanPostProcessor] is declared through a non-static factory method on that class; consider declaring it as static instead. 2025-05-27T16:37:46.023+08:00 WARN 11 --- [auth-center] [ main] [ ] trationDelegate$BeanPostProcessorChecker : Bean &#39;org.springframework.cloud.client.loadbalancer.reactive.LoadBalancerBeanPostProcessorAutoConfiguration$ReactorDeferringLoadBalancerFilterConfig&#39; of type [org.springframework.cloud.client.loadbalancer.reactive.LoadBalancerBeanPostProcessorAutoConfiguration$ReactorDeferringLoadBalancerFilterConfig] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected/applied to a currently created BeanPostProcessor [loadBalancerWebClientBuilderBeanPostProcessor]? Check the corresponding BeanPostProcessor declaration and its dependencies/advisors. If this bean does not have to be post-processed, declare it with ROLE_INFRASTRUCTURE. 2025-05-27T16:37:46.031+08:00 WARN 11 --- [auth-center] [ main] [ ] trationDelegate$BeanPostProcessorChecker : Bean &#39;reactorDeferringLoadBalancerExchangeFilterFunction&#39; of type [org.springframework.cloud.client.loadbalancer.reactive.DeferringLoadBalancerExchangeFilterFunction] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected/applied to a currently created BeanPostProcessor [loadBalancerWebClientBuilderBeanPostProcessor]? Check the corresponding BeanPostProcessor declaration and its dependencies/advisors. If this bean does not have to be post-processed, declare it with ROLE_INFRASTRUCTURE. 2025-05-27T16:37:49.032+08:00 ERROR 11 --- [auth-center] [ main] [ ] com.tongtech.commons.license.b.d : Remaining service days of the product: 10 2025-05-27T16:37:49.034+08:00 ERROR 11 --- [auth-center] [ main] [ ] c.t.commons.license.DefaultHandler : ********************************************************** The authorization certificate is about to expire Warning ********************************************************** Description: The validity period of your company`s authorization certificate is about to expire. The expiration date is 2025-06-06, and the remaining date is 10 day. Action: It is recommended to contact the sales or after-sales staff of TongTech as soon as possible to update the authorization certificate to ensure normal use of business applications 2025-05-27T16:38:08.617+08:00 WARN 11 --- [auth-center] [ main] [ ] org.hibernate.orm.deprecation : HHH90000025: Kingbase8Dialect does not need to be specified explicitly using &#39;hibernate.dialect&#39; (remove the property setting and it will be selected by default) 2025-05-27T16:38:26.457+08:00 WARN 11 --- [auth-center] [ main] [ ] org.hibernate.orm.deprecation : HHH90000025: Kingbase8Dialect does not need to be specified explicitly using &#39;hibernate.dialect&#39; (remove the property setting and it will be selected by default) 2025-05-27T16:38:51.895+08:00 WARN 11 --- [auth-center] [ main] [ ] r$InitializeUserDetailsManagerConfigurer : Global AuthenticationManager configured with an AuthenticationProvider bean. UserDetailsService beans will not be used for username/password login. Consider removing the AuthenticationProvider bean. Alternatively, consider using the UserDetailsService in a manually instantiated DaoAuthenticationProvider. 2025-05-27T16:39:09.169+08:00 INFO 11 --- [auth-center] [ main] [ ] h.c.a.c.WebServiceConfig$$SpringCGLIB$$0 : thirdPartyAppWebService webService ????????? 2025-05-27T16:39:28.105+08:00 INFO 11 --- [auth-center] [ main] [ ] c.hd.cloud.auth.AuthServerApplication : Started AuthServerApplication in 150.203 seconds (process running for 156.731) 耗时分析
最新发布
05-28
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值