|
Hibernate example source code file (AbstractExecutable.java)
The Hibernate AbstractExecutable.java source codepackage org.hibernate.test.instrument.cases; import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Environment; import org.hibernate.service.ServiceRegistry; import org.hibernate.testing.ServiceRegistryBuilder; /** * @author Steve Ebersole */ public abstract class AbstractExecutable implements Executable { private ServiceRegistry serviceRegistry; private SessionFactory factory; public final void prepare() { 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() ); factory = cfg.buildSessionFactory( serviceRegistry ); } public final void complete() { try { cleanup(); } finally { factory.close(); if ( serviceRegistry != null ) { ServiceRegistryBuilder.destroy( serviceRegistry ); } } } protected SessionFactory getFactory() { return factory; } protected void cleanup() { } protected String[] getResources() { return new String[] { "org/hibernate/test/instrument/domain/Documents.hbm.xml" }; } } Other Hibernate examples (source code examples)Here is a short list of links related to this Hibernate AbstractExecutable.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.