mirror of
https://github.com/OkaeriPoland/okaeri-timings.git
synced 2026-01-19 09:52:32 +01:00
Create backend skeleton
This commit is contained in:
13
backend/dataaccess/build.gradle
Normal file
13
backend/dataaccess/build.gradle
Normal file
@@ -0,0 +1,13 @@
|
||||
dependencies {
|
||||
|
||||
implementation 'org.springframework.boot:spring-boot-starter-cache'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-validation'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-data-rest'
|
||||
|
||||
runtimeOnly 'mysql:mysql-connector-java'
|
||||
runtimeOnly 'com.h2database:h2'
|
||||
|
||||
implementation 'com.github.f4b6a3:uuid-creator:4.3.1'
|
||||
}
|
||||
0
backend/dataaccess/src/main/java/.gitkeep
Normal file
0
backend/dataaccess/src/main/java/.gitkeep
Normal file
@@ -0,0 +1,38 @@
|
||||
package eu.okaeri.timings.dataaccess.util;
|
||||
|
||||
import com.github.f4b6a3.uuid.UuidCreator;
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.id.UUIDGenerator;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
import org.hibernate.type.Type;
|
||||
import org.hibernate.type.descriptor.java.UUIDTypeDescriptor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Properties;
|
||||
import java.util.UUID;
|
||||
|
||||
public class UUID6Generator extends UUIDGenerator {
|
||||
|
||||
private UUIDTypeDescriptor.ValueTransformer valueTransformer;
|
||||
|
||||
@Override
|
||||
public void configure(Type type, Properties params, ServiceRegistry serviceRegistry) throws MappingException {
|
||||
if (UUID.class.isAssignableFrom(type.getReturnedClass())) {
|
||||
this.valueTransformer = UUIDTypeDescriptor.PassThroughTransformer.INSTANCE;
|
||||
} else if (String.class.isAssignableFrom(type.getReturnedClass())) {
|
||||
this.valueTransformer = UUIDTypeDescriptor.ToStringTransformer.INSTANCE;
|
||||
} else {
|
||||
if (!byte[].class.isAssignableFrom(type.getReturnedClass())) {
|
||||
throw new HibernateException("Unanticipated return type [" + type.getReturnedClass().getName() + "] for UUID conversion");
|
||||
}
|
||||
this.valueTransformer = UUIDTypeDescriptor.ToBytesTransformer.INSTANCE;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Serializable generate(SharedSessionContractImplementor session, Object object) throws HibernateException {
|
||||
return this.valueTransformer.transform(UuidCreator.getTimeOrderedWithRandom());
|
||||
}
|
||||
}
|
||||
0
backend/dataaccess/src/main/resources/.gitkeep
Normal file
0
backend/dataaccess/src/main/resources/.gitkeep
Normal file
Reference in New Issue
Block a user