Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ For seamless type support in Hibernate ORM, you should pick one of the following

| Hibernate Version | Artifact |
|-------------------------------|----------------------------------------------------------------------------------------------------------------------|
| 7.2 | [org.framefork:typed-ids-hibernate-72](https://central.sonatype.com/artifact/org.framefork/typed-ids-hibernate-72) |
| 7.0, 7.1 | [org.framefork:typed-ids-hibernate-70](https://central.sonatype.com/artifact/org.framefork/typed-ids-hibernate-70) |
| 6.6, 6.5, 6.4, and 6.3 | [org.framefork:typed-ids-hibernate-63](https://central.sonatype.com/artifact/org.framefork/typed-ids-hibernate-63) |
| 6.2 | [org.framefork:typed-ids-hibernate-62](https://central.sonatype.com/artifact/org.framefork/typed-ids-hibernate-62) |
Expand Down
11 changes: 6 additions & 5 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,16 @@ hibernate-orm-v62 = { group = "org.hibernate.orm", name = "hibernate-core", vers
hibernate-orm-v63 = { group = "org.hibernate.orm", name = "hibernate-core", version = "6.3.2.Final" }
hibernate-orm-v64 = { group = "org.hibernate.orm", name = "hibernate-core", version = "6.4.10.Final" }
hibernate-orm-v65 = { group = "org.hibernate.orm", name = "hibernate-core", version = "6.5.3.Final" }
hibernate-orm-v66 = { group = "org.hibernate.orm", name = "hibernate-core", version = "6.6.36.Final" }
hibernate-orm-v66 = { group = "org.hibernate.orm", name = "hibernate-core", version = "6.6.38.Final" }
hibernate-orm-v70 = { group = "org.hibernate.orm", name = "hibernate-core", version = "7.0.10.Final" }
hibernate-orm-v71 = { group = "org.hibernate.orm", name = "hibernate-core", version = "7.1.9.Final" }
hibernate-orm-v71 = { group = "org.hibernate.orm", name = "hibernate-core", version = "7.1.11.Final" }
hibernate-orm-v72 = { group = "org.hibernate.orm", name = "hibernate-core", version = "7.2.0.Final" }
hibernate-models-v70 = { group = "org.hibernate.models", name = "hibernate-models", version = "1.0.0" }
hypersistence-utils-hibernate61 = { group = "io.hypersistence", name = "hypersistence-utils-hibernate-60", version = "3.9.4" }
hypersistence-utils-hibernate62 = { group = "io.hypersistence", name = "hypersistence-utils-hibernate-62", version = "3.9.4" }
hypersistence-utils-hibernate63 = { group = "io.hypersistence", name = "hypersistence-utils-hibernate-63", version = "3.12.0" }
hypersistence-utils-hibernate70 = { group = "io.hypersistence", name = "hypersistence-utils-hibernate-70", version = "3.12.0" }
hypersistence-utils-hibernate71 = { group = "io.hypersistence", name = "hypersistence-utils-hibernate-71", version = "3.12.0" }
hypersistence-utils-hibernate63 = { group = "io.hypersistence", name = "hypersistence-utils-hibernate-63", version = "3.13.3" }
hypersistence-utils-hibernate70 = { group = "io.hypersistence", name = "hypersistence-utils-hibernate-70", version = "3.13.3" }
hypersistence-utils-hibernate71 = { group = "io.hypersistence", name = "hypersistence-utils-hibernate-71", version = "3.13.3" }
hypersistence-tsid = { module = "io.hypersistence:hypersistence-tsid", version = "2.1.4" }
kotlinx-serialization = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version = "1.7.0" }
swagger-v3-core-jakarta = { module = "io.swagger.core.v3:swagger-core-jakarta", version = "2.2.35" }
Expand Down
11 changes: 11 additions & 0 deletions modules/typed-ids-hibernate-72-testing/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
plugins {
id("framefork.java")
}

dependencies {
api(project(":typed-ids-testing"))
api(testFixtures(project(":typed-ids-hibernate-72")))

api(libs.hibernate.orm.v72)
api(libs.hypersistence.utils.hibernate71)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package org.framefork.typedIds.hibernate.tests;

import io.hypersistence.utils.test.providers.DataSourceProvider;
import org.testcontainers.containers.JdbcDatabaseContainer;

import javax.sql.DataSource;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicReference;

public abstract class AbstractContainerDataSourceProvider implements DataSourceProvider
{

private final AtomicReference<JdbcDatabaseContainer<?>> container = new AtomicReference<>();

public JdbcDatabaseContainer<?> getContainer()
{
if (container.get() == null) {
synchronized (container) {
if (container.get() == null) {
container.set(initContainer());
}
}
}

return Objects.requireNonNull(container.get(), "database container must not be null");
}

private JdbcDatabaseContainer<?> initContainer()
{
var newContainer = (JdbcDatabaseContainer<?>) newJdbcDatabaseContainer();

if (supportsDatabaseName()) {
newContainer.withDatabaseName(databaseName());
}
if (supportsCredentials()) {
newContainer.withUsername(username()).withPassword(password());
}

newContainer.withReuse(true).start();

return newContainer;
}

@Override
public final DataSource dataSource()
{
getContainer(); // force init
return newDataSource();
}

@Override
public final String url()
{
return getContainer().getJdbcUrl();
}

public String databaseName()
{
return "framefork";
}

protected abstract DataSource newDataSource();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.framefork.typedIds.hibernate.tests;

import io.hypersistence.utils.test.AbstractHibernateTest;
import io.hypersistence.utils.test.providers.DataSourceProvider;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;

public abstract class AbstractMySQLIntegrationTest extends AbstractHibernateTest
{

@BeforeEach
@Override
public void init()
{
super.init();
}

@AfterEach
@Override
public void destroy()
{
super.destroy();
}

@Override
protected DataSourceProvider dataSourceProvider()
{
return MySQLDataSourceProvider.V8;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.framefork.typedIds.hibernate.tests;

import io.hypersistence.utils.test.AbstractHibernateTest;
import io.hypersistence.utils.test.providers.DataSourceProvider;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;

public abstract class AbstractPostgreSQLIntegrationTest extends AbstractHibernateTest
{

@BeforeEach
@Override
public void init()
{
super.init();
}

@AfterEach
@Override
public void destroy()
{
super.destroy();
}

@Override
protected DataSourceProvider dataSourceProvider()
{
return PostgreSQLDataSourceProvider.V16;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package org.framefork.typedIds.hibernate.tests;

import com.mysql.cj.jdbc.MysqlDataSource;
import org.hibernate.dialect.Database;
import org.hibernate.dialect.MySQLDialect;
import org.testcontainers.containers.JdbcDatabaseContainer;
import org.testcontainers.containers.MySQLContainer;

import javax.sql.DataSource;
import java.util.Map;

public final class MySQLDataSourceProvider extends AbstractContainerDataSourceProvider
{

public static final MySQLDataSourceProvider V8 = new MySQLDataSourceProvider("8.4");

private final String version;

private MySQLDataSourceProvider(final String version)
{
this.version = version;
}

@Override
public Database database()
{
return Database.MYSQL;
}

@Override
public String hibernateDialect()
{
return MySQLDialect.class.getName();
}

@Override
protected DataSource newDataSource()
{
var dataSource = new MysqlDataSource();
dataSource.setURL(url());
dataSource.setUser(username());
dataSource.setPassword(password());
return dataSource;
}

@Override
public String username()
{
return "mysql";
}

@Override
public String password()
{
return "admin";
}

@SuppressWarnings({"rawtypes", "unchecked"})
@Override
public JdbcDatabaseContainer newJdbcDatabaseContainer()
{
var container = new MySQLContainer("mysql:" + version);
container.withTmpFs(Map.of("/var/lib/mysql", "rw"));
return container;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package org.framefork.typedIds.hibernate.tests;

import org.hibernate.dialect.Database;
import org.hibernate.dialect.PostgreSQLDialect;
import org.postgresql.ds.PGSimpleDataSource;
import org.testcontainers.containers.JdbcDatabaseContainer;
import org.testcontainers.containers.PostgreSQLContainer;

import javax.sql.DataSource;
import java.util.Map;

public final class PostgreSQLDataSourceProvider extends AbstractContainerDataSourceProvider
{

public static final PostgreSQLDataSourceProvider V16 = new PostgreSQLDataSourceProvider("16.4");

private final String version;

private PostgreSQLDataSourceProvider(final String version)
{
this.version = version;
}

@Override
public Database database()
{
return Database.POSTGRESQL;
}

@Override
public String hibernateDialect()
{
return PostgreSQLDialect.class.getName();
}

@Override
protected DataSource newDataSource()
{
var dataSource = new PGSimpleDataSource();
dataSource.setURL(url());
dataSource.setUser(username());
dataSource.setPassword(password());

return dataSource;
}

@Override
public String username()
{
return "postgres";
}

@Override
public String password()
{
return "admin";
}

@SuppressWarnings({"rawtypes", "unchecked"})
@Override
public JdbcDatabaseContainer newJdbcDatabaseContainer()
{
var container = new PostgreSQLContainer("postgres:" + version);
container.withCommand("postgres", "-c", "fsync=off", "-c", "random_page_cost=1.0", "-c", "synchronous_commit=off", "-c", "full_page_writes=off");
container.withEnv(Map.of("PGDATA", "/var/lib/postgresql/data"));
container.withTmpFs(Map.of("/var/lib/postgresql/data", "rw"));
return container;
}

}
20 changes: 20 additions & 0 deletions modules/typed-ids-hibernate-72/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
plugins {
id("framefork.java-public")
id("java-test-fixtures")
}

dependencies {
api(project(":typed-ids"))
api(libs.hibernate.orm.v72)
compileOnly(libs.hibernate.models.v70) // this is really a runtime dependency, but in runtime the version from hibernate is provided

compileOnly(libs.jetbrains.annotations)

compileOnly(libs.autoService.annotations)
annotationProcessor(libs.autoService.processor)

testImplementation(project(":typed-ids-hibernate-72-testing"))
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}

project.description = "TypeIds seamless integration into Hibernate ORMs type system"
Loading