HHH-7919 : Miscellaneous bugfixes

This commit is contained in:
Strong Liu 2013-06-09 05:17:49 +08:00
parent 9bb0b2a7f3
commit 1b9ca7df6c
3 changed files with 27 additions and 13 deletions

View File

@ -23,22 +23,25 @@
*/ */
package org.hibernate.test.formulajoin; package org.hibernate.test.formulajoin;
import org.hibernate.cfg.Configuration;
import org.junit.Test; import org.junit.Test;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseUnitTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
/** /**
* @author Steve Ebersole * @author Steve Ebersole
*/ */
public class AnnotatedFormWithBeanValidationNotNullTest extends BaseUnitTestCase { public class AnnotatedFormWithBeanValidationNotNullTest extends BaseCoreFunctionalTestCase {
@Override
protected Class<?>[] getAnnotatedClasses() {
return new Class[] { AnnotatedMaster.class, AnnotatedDetail.class };
}
@Test @Test
@TestForIssue( jiraKey = "HHH-8167" ) @TestForIssue(jiraKey = "HHH-8167")
public void testAnnotatedFormWithBeanValidationNotNull() { public void testAnnotatedFormWithBeanValidationNotNull() {
Configuration cfg = new Configuration(); //doing noting, we here only testing the mapping binding
cfg.addAnnotatedClass( AnnotatedMaster.class ).addAnnotatedClass( AnnotatedDetail.class );
cfg.buildSessionFactory();
} }
} }

View File

@ -3,8 +3,10 @@
import org.hibernate.SessionFactory; import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment; import org.hibernate.cfg.Environment;
import org.hibernate.metamodel.MetadataSources;
import org.hibernate.service.ServiceRegistry; import org.hibernate.service.ServiceRegistry;
import org.hibernate.testing.ServiceRegistryBuilder; import org.hibernate.testing.ServiceRegistryBuilder;
import org.hibernate.testing.junit4.BaseUnitTestCase;
/** /**
* @author Steve Ebersole * @author Steve Ebersole
@ -16,12 +18,21 @@ public abstract class AbstractExecutable implements Executable {
@Override @Override
public final void prepare() { public final void prepare() {
Configuration cfg = new Configuration().setProperty( Environment.HBM2DDL_AUTO, "create-drop" ); Configuration cfg = new Configuration().setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
String[] resources = getResources();
for ( String resource : resources ) {
cfg.addResource( resource );
}
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( cfg.getProperties() ); serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( cfg.getProperties() );
factory = cfg.buildSessionFactory( serviceRegistry ); String[] resources = getResources();
if( BaseUnitTestCase.isMetadataUsed()){
MetadataSources metadataSources = new MetadataSources( serviceRegistry );
for(String resource : resources){
metadataSources.addResource( resource );
}
factory = metadataSources.buildMetadata().buildSessionFactory();
}else{
for ( String resource : resources ) {
cfg.addResource( resource );
}
factory = cfg.buildSessionFactory( serviceRegistry );
}
} }
@Override @Override
public final void complete() { public final void complete() {

View File

@ -52,7 +52,7 @@ public abstract class BaseUnitTestCase {
*/ */
protected static final String OUTPUT_PREFIX = SqlStatementLogger.OUTPUT_PREFIX; protected static final String OUTPUT_PREFIX = SqlStatementLogger.OUTPUT_PREFIX;
protected static boolean isMetadataUsed = Boolean.valueOf( System.getProperty( USE_NEW_METADATA_MAPPINGS, "true" ) ); protected static boolean isMetadataUsed = Boolean.valueOf( System.getProperty( USE_NEW_METADATA_MAPPINGS, "true" ) );
protected static boolean isMetadataUsed() { public static boolean isMetadataUsed() {
return isMetadataUsed; return isMetadataUsed;
} }
@Rule @Rule