Skip to content

Commit

Permalink
Add SchemaExport
Browse files Browse the repository at this point in the history
  • Loading branch information
kifj committed Feb 17, 2024
1 parent 1294743 commit dba90f7
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 2 deletions.
19 changes: 18 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<jacoco.version>0.8.10</jacoco.version>
<arquillian.version>1.8.0.Final</arquillian.version>
<arquillian.wildfly.version>5.0.1.Final</arquillian.wildfly.version>
<jkube.version>1.15.0</jkube.version>
<jkube.version>1.16.0</jkube.version>
</properties>

<distributionManagement>
Expand Down Expand Up @@ -202,6 +202,7 @@
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
Expand Down Expand Up @@ -348,6 +349,22 @@
<version>42.7.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-ant</artifactId>
<version>6.4.2.Final</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml</groupId>
<artifactId>classmate</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate.common</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.logmanager</groupId>
<artifactId>jboss-logmanager</artifactId>
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/x1/stomp/model/Action.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package x1.stomp.model;

import org.eclipse.microprofile.openapi.annotations.media.Schema;

@Schema(description = "Executable action")
public enum Action {
SUBSCRIBE,
UNSUBSCRIBE
Expand Down
1 change: 1 addition & 0 deletions src/main/java/x1/stomp/model/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
@XmlRootElement(name = "command")
@JsonRootName(value = "command")
@JsonInclude(value = JsonInclude.Include.NON_NULL)
@Schema(description = "Action to execute for a share")
public class Command {
@NotNull
private Action action;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/x1/stomp/model/Share.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public Share(@NotNull @Size(min = 1, max = 25) @Pattern(regexp = "[A-Z0-9.]*",
@NotNull
@Size(min = 1, max = 25)
@Pattern(regexp = "[A-Z0-9.]*", message = "must contain only letters and dots")
@Column
@Column(length = 25)
@Schema(required = true, description = "Stock symbol", example = "MSFT")
@XmlAttribute
private String key;
Expand Down
24 changes: 24 additions & 0 deletions src/test/java/x1/stomp/test/SchemaExportTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package x1.stomp.test;

import java.util.EnumSet;

import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.dialect.PostgreSQLDialect;
import org.hibernate.tool.hbm2ddl.SchemaExport;
import org.hibernate.tool.schema.TargetType;
import org.junit.jupiter.api.Test;

import x1.stomp.model.Share;

public class SchemaExportTest {
@Test
public void testSchemaExport() {
MetadataSources metadata = new MetadataSources(
new StandardServiceRegistryBuilder().applySetting(AvailableSettings.DIALECT, PostgreSQLDialect.class.getName())
.applySetting(AvailableSettings.DEFAULT_SCHEMA, "stocks").build());
new SchemaExport().setOutputFile("target/ddl.sql").setFormat(true).create(EnumSet.of(TargetType.SCRIPT),
metadata.addAnnotatedClass(Share.class).buildMetadata());
}
}

0 comments on commit dba90f7

Please sign in to comment.