made incomplete misc changes

This commit is contained in:
Zhongheng Liu 2024-01-14 14:52:32 +02:00
commit 8259f6cc49
No known key found for this signature in database
4 changed files with 51 additions and 6 deletions

View file

@ -0,0 +1,14 @@
package me.imsonmia.epqapi.config;
import org.hibernate.dialect.MariaDBDialect;
/**
* MySQLCustomDialect
*/
public class MySQLCustomDialect extends MariaDBDialect {
// https://stackoverflow.com/questions/42430786/how-to-set-collation-for-table-attribute-as-utf8-bin-in-either-annotation-or-app#54993738
@Override
public String getTableTypeString() {
return " ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci";
}
}

View file

@ -1,6 +1,7 @@
package me.imsonmia.epqapi.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.lang.NonNull;
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
@ -10,12 +11,12 @@ import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerCo
@EnableWebSocketMessageBroker
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {
@Override
public void configureMessageBroker(MessageBrokerRegistry registry) {
public void configureMessageBroker(@NonNull MessageBrokerRegistry registry) {
registry.enableSimpleBroker("/sub");
registry.setApplicationDestinationPrefixes("/app");
}
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
public void registerStompEndpoints(@NonNull StompEndpointRegistry registry) {
registry.addEndpoint("/ws").setAllowedOrigins("*");
}

View file

@ -0,0 +1,21 @@
package me.imsonmia.epqapi.view;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.lang.Nullable;
import jakarta.persistence.criteria.CriteriaBuilder;
import jakarta.persistence.criteria.CriteriaQuery;
import jakarta.persistence.criteria.Predicate;
import jakarta.persistence.criteria.Root;
import me.imsonmia.epqapi.model.Message;
public class MessageSpecification implements Specification {
@Override
@Nullable
public Predicate toPredicate(Root root, CriteriaQuery query, CriteriaBuilder builder) {
// TODO Auto-generated method stub
return null;
}
}

View file

@ -1,6 +1,15 @@
spring.datasource.url=jdbc:mariadb://127.0.0.1:3306/test?useUnicode=true&characterEncoding=UTF-8
spring.datasource.username=dbuser
spring.datasource.password=dbpasswd
spring.datasource.url=jdbc:mariadb://127.0.0.1:3306/epqchat
spring.datasource.username=epqchatuser
spring.datasource.password=epqlevel3artifact
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
# Use custom database handler to ensure that the API and database table collations
# run in UTF-8-MB4 mode. This should get rid of all the encoding issues previously present.
spring.jpa.properties.hibernate.dialect=me.imsonmia.epqapi.config.MySQLCustomDialect
spring.jpa.show-sql: true
spring.jpa.hibernate.ddl-auto=create-drop
# https://stackoverflow.com/questions/42135114/how-does-spring-jpa-hibernate-ddl-auto-property-exactly-work-in-spring
# Summarisation
# create-drop for testing
# validate for semi-production
# none for serious prod scenarios
spring.jpa.hibernate.ddl-auto=update