Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HHH-14835 : More changes to support SchemaMigrator/SchemaValidator us…
…ing Hibernate Reactive Changes required for sequences to be created with a default catalog
- Loading branch information
Showing
3 changed files
with
139 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
...rg/hibernate/test/schemaupdate/SchemaExportSqlServerWithSequenceDefaultSchemaCatalog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* | ||
* Hibernate, Relational Persistence for Idiomatic Java | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. | ||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
*/ | ||
package org.hibernate.test.schemaupdate; | ||
|
||
import java.util.EnumSet; | ||
import javax.persistence.Entity; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.Id; | ||
import javax.persistence.Table; | ||
|
||
import org.hibernate.boot.MetadataSources; | ||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder; | ||
import org.hibernate.boot.spi.MetadataImplementor; | ||
import org.hibernate.cfg.Environment; | ||
import org.hibernate.dialect.SQLServer2012Dialect; | ||
import org.hibernate.service.ServiceRegistry; | ||
import org.hibernate.tool.hbm2ddl.SchemaExport; | ||
import org.hibernate.tool.schema.TargetType; | ||
|
||
import org.hibernate.testing.RequiresDialect; | ||
import org.hibernate.testing.TestForIssue; | ||
import org.hibernate.testing.junit4.CustomRunner; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static org.hamcrest.core.Is.is; | ||
import static org.junit.Assert.assertThat; | ||
|
||
/** | ||
* @author Andrea Boriero | ||
*/ | ||
@TestForIssue(jiraKey = "HHH-XXX") | ||
@RunWith(CustomRunner.class) | ||
@RequiresDialect(SQLServer2012Dialect.class) | ||
public class SchemaExportSqlServerWithSequenceDefaultSchemaCatalog { | ||
protected ServiceRegistry serviceRegistry; | ||
protected MetadataImplementor metadata; | ||
|
||
@Test | ||
public void shouldCreateIndex() { | ||
SchemaExport schemaExport = new SchemaExport(); | ||
schemaExport.create( EnumSet.of( TargetType.DATABASE, TargetType.STDOUT ), metadata ); | ||
assertThat( schemaExport.getExceptions().size(), is( 0 ) ); | ||
} | ||
|
||
@Before | ||
public void setUp() { | ||
serviceRegistry = new StandardServiceRegistryBuilder() | ||
.applySetting( Environment.DEFAULT_SCHEMA, "dbo" ) | ||
.applySetting( Environment.DEFAULT_CATALOG, "hibernate_orm_test" ) | ||
.build(); | ||
metadata = (MetadataImplementor) new MetadataSources( serviceRegistry ) | ||
.addAnnotatedClass( MyEntity.class ) | ||
.buildMetadata(); | ||
|
||
System.out.println( "********* Starting SchemaExport for START-UP *************************" ); | ||
new SchemaExport().create( EnumSet.of( TargetType.DATABASE, TargetType.STDOUT ), metadata ); | ||
System.out.println( "********* Completed SchemaExport for START-UP *************************" ); | ||
} | ||
|
||
|
||
@After | ||
public void tearDown() { | ||
System.out.println( "********* Starting SchemaExport (drop) for TEAR-DOWN *************************" ); | ||
new SchemaExport().drop( EnumSet.of( TargetType.DATABASE, TargetType.STDOUT ), metadata ); | ||
System.out.println( "********* Completed SchemaExport (drop) for TEAR-DOWN *************************" ); | ||
|
||
StandardServiceRegistryBuilder.destroy( serviceRegistry ); | ||
serviceRegistry = null; | ||
} | ||
|
||
|
||
@Entity | ||
@Table(name = "MyEntity") | ||
public static class MyEntity { | ||
private int id; | ||
|
||
@Id | ||
@GeneratedValue | ||
public int getId() { | ||
return this.id; | ||
} | ||
|
||
public void setId(final int id) { | ||
this.id = id; | ||
} | ||
} | ||
} |