|
Hibernate example source code file (SafeMappingTest.java)
The Hibernate SafeMappingTest.java source code//$Id$ package org.hibernate.test.annotations; import org.hibernate.AnnotationException; import org.hibernate.cfg.AnnotationConfiguration; import org.hibernate.cfg.Environment; import org.hibernate.service.ServiceRegistry; import org.hibernate.testing.ServiceRegistryBuilder; /** * @author Emmanuel Bernard */ public class SafeMappingTest extends junit.framework.TestCase { public void testDeclarativeMix() throws Exception { AnnotationConfiguration cfg = new AnnotationConfiguration(); cfg.addAnnotatedClass( IncorrectEntity.class ); cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" ); ServiceRegistry serviceRegistry = null; try { serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( cfg.getProperties() ); cfg.buildSessionFactory( serviceRegistry ); fail( "Entity wo id should fail" ); } catch (AnnotationException e) { //success } finally { if ( serviceRegistry != null ) { ServiceRegistryBuilder.destroy( serviceRegistry ); } } } } Other Hibernate examples (source code examples)Here is a short list of links related to this Hibernate SafeMappingTest.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.