Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Copyright 2008,  Unitils.org
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  *     http://www.apache.org/licenses/LICENSE-2.0
  *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.unitils.orm.hibernate;
Utility facade for handling Hibernate related stuff such as asserting whether the mappings correspond to the actual structure of the database.

Author(s):
Filip Neven
Tim Ducheyne
public class HibernateUnitils {


    
Checks if the mapping of the Hibernate managed objects with the database is still correct for the configurations that are loaded for the current test.
    public static void assertMappingWithDatabaseConsistent() {
        Object testObject = getTestObject();
    }


    
Flushes all pending Hibernate updates to the database. This method is useful when the effect of updates needs to be checked directly on the database, without passing through the currently active hibernate session.
    public static void flushDatabaseUpdates() {
    	Object testObject = getTestObject();
    }
    
    
    

Returns:
The SessionFactory configured for the current test object (spring or using the org.unitils.orm.hibernate.annotation.HibernateSessionFactory annotation.
    public static SessionFactory getSessionFactory() {
    }
    
    
    

Returns:
A Session associated with the current transaction. This method returns the same Session during the course of a transaction.
    public static Session getSession() {
    }


    

Returns:
The current test object
	private static Object getTestObject() {
		Object testObject = Unitils.getInstance().getTestContext().getTestObject();
        if (testObject == null) {
            throw new UnitilsException("No current test found in context. Unable to execute specified operation");
        }
		return testObject;
	}
    
    
    

Returns:
The HibernateModule
	private static HibernateModule getHibernateModule() {
	}
New to GrepCode? Check out our FAQ X