All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hibernate.dialect.identity.Oracle12cGetGeneratedKeysDelegate Maven / Gradle / Ivy

There is a newer version: 7.0.0.Alpha1
Show newest version
/*
 * Hibernate, Relational Persistence for Idiomatic Java
 *
 * License: GNU Lesser General Public License (LGPL), version 2.1 or later.
 * See the lgpl.txt file in the root directory or .
 */
package org.hibernate.dialect.identity;

import java.sql.PreparedStatement;
import java.sql.SQLException;

import org.hibernate.HibernateException;
import org.hibernate.dialect.Dialect;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.id.PostInsertIdentityPersister;

/**
 * @author Andrea Boriero
 */
public class Oracle12cGetGeneratedKeysDelegate extends GetGeneratedKeysDelegate {
	private String[] keyColumns;

	public Oracle12cGetGeneratedKeysDelegate(PostInsertIdentityPersister persister, Dialect dialect) {
		super( persister, dialect );
		this.keyColumns = getPersister().getRootTableKeyColumnNames();
		if ( keyColumns.length > 1 ) {
			throw new HibernateException( "Identity generator cannot be used with multi-column keys" );
		}

	}

	@Override
	protected PreparedStatement prepare(String insertSQL, SharedSessionContractImplementor session) throws SQLException {
		return session
				.getJdbcCoordinator()
				.getStatementPreparer()
				.prepareStatement( insertSQL, keyColumns );
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy