Skip to content

Commit

Permalink
Merge pull request #165 from Thadoy/h2support
Browse files Browse the repository at this point in the history
Add h2 database config
  • Loading branch information
YukiInu authored Jul 26, 2024
2 parents 1238c67 + 07aee89 commit f7fdd8f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
* Breaking: Removed Junit 5 Vintage engine and Junit 4 (can be added in projects that need it)
* Fixed vulnerabilities: CVE-2023-52428(nimbus-jose-jwt), CVE-2024-29857,CVE-2024-30171,CVE-2024-30172,CVE-2024-34447 (bouncycastle), CVE-2024-28752 (Apache CXF)
* Corrected the use of @Nullable and @Nonnull annotations on created ivos and events, especially on the generated builders
* Add support for h2 embedded database

# 1.35
* Update dependencies
Expand Down
30 changes: 30 additions & 0 deletions jpa/src/main/java/de/taimos/dvalin/jpa/config/H2Config.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package de.taimos.dvalin.jpa.config;

import de.taimos.daemon.spring.conditional.OnSystemProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseFactoryBean;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;

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

/**
* Copyright 2024 Cinovo AG<br>
* <br>
*
* @author fzwirn
*/
@Configuration
@OnSystemProperty(propertyName = "ds.type", propertyValue = "H2")
public class H2Config {
@Bean
public DataSource dataSource() {
EmbeddedDatabaseFactoryBean factoryBean = new EmbeddedDatabaseFactoryBean();
// randomize database name to get a new one each time
factoryBean.setDatabaseName(UUID.randomUUID().toString());
factoryBean.setDatabaseType(EmbeddedDatabaseType.H2);
factoryBean.afterPropertiesSet();
return factoryBean.getObject();
}
}

0 comments on commit f7fdd8f

Please sign in to comment.