-
Notifications
You must be signed in to change notification settings - Fork 100
How to find out why Blaze uses the wrong dialect? #2033
Replies: 1 comment · 2 replies
-
Hi, can you share the stack trace please? Also, please share the dialect configuration. Also, does your dialect extend the MySQL one? |
Beta Was this translation helpful? Give feedback.
All reactions
-
I don't have a custom blaze dialect. As I understand it blaze already includes dialects for MySQL, right? But why doesn't it use it? How can I tell blaze, which dialect it should use? Here's the stack trace:
Here's the connection config: @Configuration
@EnableAutoConfiguration
@EnableTransactionManagement
@EnableJpaRepositories(
// packages where to search for repository classes
basePackageClasses = {Repos.class},
entityManagerFactoryRef = "primaryEntityManagerFactory",
transactionManagerRef = "primaryTransactionManager"
)
@EnableJpaAuditing
public class DatabaseConfig
{
// qualifiers
public static final String PERSISTENCE_UNIT = "primary";
public static final String DATA_SOURCE_NAME = "dataSource";
public static final String ENTITY_MANAGER_FACTORY_NAME = "primaryEntityManagerFactory";
public static final String TRANSACTION_MANAGER_NAME = "primaryTransactionManager";
@Autowired
private Environment env;
@Primary
@Bean(DATA_SOURCE_NAME)
@ConfigurationProperties(prefix = "database.source")
@QuartzDataSource
public DataSource dataSource() {
return DataSourceBuilder.create().build();
}
private Map<String, Object> jpaProperties() {
final Map<String, Object> props = new HashMap<>();
props.put("hibernate.show_sql", env.getProperty("database.hibernate.showSql"));
props.put("hibernate.use_sql_comments", env.getProperty("database.hibernate.useSqlComments"));
props.put("hibernate.format_sql", env.getProperty("database.hibernate.formatSql"));
props.put("hibernate.generate_statistics", env.getProperty("database.hibernate.generateStats"));
props.put("hibernate.hbm2ddl.auto", env.getProperty("database.hibernate.ddlAuto"));
props.put("hibernate.dialect", env.getProperty("database.hibernate.dialect"));
props.put("hibernate.jdbc.time_zone", env.getProperty("database.hibernate.timezone"));
props.put("hibernate.physical_naming_strategy", PhysicalNamingStrategy.class.getName());
props.put("hibernate.implicit_naming_strategy", SpringImplicitNamingStrategy.class.getName());
return props;
}
@Primary
@Bean(ENTITY_MANAGER_FACTORY_NAME)
public LocalContainerEntityManagerFactoryBean entityManagerFactory(
EntityManagerFactoryBuilder builder,
@Qualifier(DATA_SOURCE_NAME) DataSource dataSource) {
return builder
.dataSource(dataSource)
.packages(Entities.class) // packages where to search for entity classes
.persistenceUnit(PERSISTENCE_UNIT)
.properties(jpaProperties())
.build();
}
@Primary
@Bean(TRANSACTION_MANAGER_NAME)
public PlatformTransactionManager transactionManager(
@Qualifier(ENTITY_MANAGER_FACTORY_NAME) EntityManagerFactory entityManagerFactory) {
return new JpaTransactionManager(entityManagerFactory);
}
@Bean
public SessionAuditorAware auditorProvider() {
return new SessionAuditorAware();
}
} And in our database:
source:
# ...
hibernate:
showSql: false #true
formatSql: false
useSqlComments: false
generateStats: false
ddlAuto: none # migrations done by 'flyway' (none, validate, update, create, create-drop)
timezone: UTC
dialect: org.hibernate.dialect.MariaDBDialect |
Beta Was this translation helpful? Give feedback.
All reactions
-
So the stack trace actually shows that the HQL which is created by Blaze-Persistence fails and as far as I can tell, this might be due to the querydsl integration rendering something wrong. It misses the quotes around |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I try to use blaze querydsl extensions with spring boot 2.7.18 with a MySQL DB. For some reason it seems to use the wrong dialect:
When I use
groupConcat()
it creates the wrong SQL:GROUP_CONCAT(projectEntity.name, 'SEPARATOR', '$$$', 'ORDER BY', projectEntity.createdAt, DESC)
I assume that the dialect is somehow obtained from Hibernate. Here we use our custom connection configuration with
LocalContainerEntityManagerFactoryBean
where the correct hibernate dialect is set.Could this maybe break the detection of the dialect? Can we manually configure the correct dialect for blaze somehow?
Beta Was this translation helpful? Give feedback.
All reactions