HHH-9849 - Add test for issue

This commit is contained in:
Andrea Boriero 2015-06-12 13:34:58 +01:00
parent 2f1b67b03f
commit 9024ff55d6
1 changed files with 115 additions and 0 deletions

View File

@ -0,0 +1,115 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) {DATE}, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.schemaupdate;
import javax.persistence.Column;
import javax.persistence.Entity;
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.MySQLDialect;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.tool.hbm2ddl.SchemaExport;
import org.hibernate.tool.hbm2ddl.SchemaUpdate;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.hibernate.testing.RequiresDialect;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.CustomRunner;
/**
* @author Andrea Boriero
*/
@TestForIssue(jiraKey = "HHH-9849")
@RunWith(CustomRunner.class)
@RequiresDialect(MySQLDialect.class)
public class MixedFieldPropertyAnnotationTest {
protected ServiceRegistry serviceRegistry;
protected MetadataImplementor metadata;
@Test
public void testUpdateSchema() throws Exception {
new SchemaUpdate(
metadata
).execute( true, true );
}
@Entity
@Table(name = "MyEntity")
class MyEntity {
@Id
public int getId() {
return 0;
}
@Column(name = "Ul")
public int getValue() {
return 0;
}
public void setId(final int _id) {
}
public void setValue(int value) {
}
}
@Before
public void setUp() {
serviceRegistry = new StandardServiceRegistryBuilder().applySetting(
Environment.GLOBALLY_QUOTED_IDENTIFIERS,
"false"
).build();
metadata = (MetadataImplementor) new MetadataSources( serviceRegistry )
.addAnnotatedClass( MyEntity.class )
.buildMetadata();
System.out.println( "********* Starting SchemaExport for START-UP *************************" );
SchemaExport schemaExport = new SchemaExport( serviceRegistry, metadata );
schemaExport.create( true, true );
System.out.println( "********* Completed SchemaExport for START-UP *************************" );
}
@After
public void tearDown() {
System.out.println( "********* Starting SchemaExport (drop) for TEAR-DOWN *************************" );
SchemaExport schemaExport = new SchemaExport( serviceRegistry, metadata );
schemaExport.drop( true, true );
System.out.println( "********* Completed SchemaExport (drop) for TEAR-DOWN *************************" );
StandardServiceRegistryBuilder.destroy( serviceRegistry );
serviceRegistry = null;
}
}