Java Code Examples for org.hibernate.engine.spi.SessionImplementor#connection()

The following examples show how to use org.hibernate.engine.spi.SessionImplementor#connection() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: HibernateDemos   File: MultiTenancyDemo.java    License: The Unlicense 5 votes vote down vote up
private static void createTable(String tenantId) {
	// Multi-tenancy does not currently support schema export, so manually create it here.
	try {
		final Session s = openSession( tenantId );
		final SessionImplementor sImpl = (SessionImplementor) s;
		final Connection conn = sImpl.connection();
		final Statement stmt = conn.createStatement();
		stmt.executeUpdate( "CREATE TABLE Project (id bigint generated by default as identity, name varchar(255), primary key (id))" );
		stmt.close();
		s.close();
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
Example 2
private static void createTable(String tenantId) {
	// Multi-tenancy does not currently support schema export, so manually create it here.
	try {
		final Session s = openSession( tenantId );
		final SessionImplementor sImpl = (SessionImplementor) s;
		final Connection conn = sImpl.connection();
		final Statement stmt = conn.createStatement();
		stmt.executeUpdate( "CREATE TABLE Project (id bigint generated by default as identity, name varchar(255), primary key (id))" );
		stmt.close();
		s.close();
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
Example 3
@NonNull
@Override
public Connection getConnection() {
    final SessionImplementor session = (SessionImplementor) sessionFactory.getCurrentSession();
    return session.connection();
}
 
Example 4
@NonNull
@Override
public Connection getConnection() {
    final SessionImplementor session = (SessionImplementor) sessionFactory.getCurrentSession();
    return session.connection();
}