@Override protected Serializable getResult( SharedSessionContractImplementor session, ResultSet rs, Object object) throws SQLException { return IdentifierGeneratorHelper.getGeneratedIdentity( rs, persister.getRootTableKeyColumnNames()[0], persister.getIdentifierType(), session.getJdbcServices().getJdbcEnvironment().getDialect() ); } }
@Override protected String getSelectSQL() { return persister.getIdentitySelectString(); }
private SelectGeneratorDelegate( PostInsertIdentityPersister persister, Dialect dialect, String suppliedUniqueKeyPropertyName) { super( persister ); this.persister = persister; this.dialect = dialect; this.uniqueKeyPropertyName = determineNameOfPropertyToUse( persister, suppliedUniqueKeyPropertyName ); idSelectString = persister.getSelectByUniqueKeyString( uniqueKeyPropertyName ); uniqueKeyType = persister.getPropertyType( uniqueKeyPropertyName ); idType = persister.getIdentifierType(); }
private static String determineNameOfPropertyToUse(PostInsertIdentityPersister persister, String supplied) { if ( supplied != null ) { return supplied; } int[] naturalIdPropertyIndices = persister.getNaturalIdentifierProperties(); if ( naturalIdPropertyIndices == null ) { throw new IdentifierGenerationException( "no natural-id property defined; need to specify [key] in " + "generator parameters" ); } if ( naturalIdPropertyIndices.length > 1 ) { throw new IdentifierGenerationException( "select generator does not currently support composite " + "natural-id properties; need to specify [key] in generator parameters" ); } if ( persister.getEntityMetamodel().isNaturalIdentifierInsertGenerated() ) { throw new IdentifierGenerationException( "natural-id also defined as insert-generated; need to specify [key] " + "in generator parameters" ); } return persister.getPropertyNames()[naturalIdPropertyIndices[0]]; }
@Override public IdentifierGeneratingInsert prepareIdentifierGeneratingInsert() { IdentifierGeneratingInsert insert = new IdentifierGeneratingInsert( dialect ); insert.addIdentityColumn( persister.getRootTableKeyColumnNames()[0] ); return insert; }
public Serializable executeAndExtract(PreparedStatement insert) throws SQLException { insert.executeUpdate(); ResultSet rs = null; try { rs = insert.getGeneratedKeys(); return IdentifierGeneratorHelper.getGeneratedIdentity( rs, persister.getIdentifierColumnNames()[0], persister.getIdentifierType() ); } finally { if ( rs != null ) { rs.close(); } } } }
protected Serializable getResult( SessionImplementor session, ResultSet rs, Object object) throws SQLException { return IdentifierGeneratorFactory.getGeneratedIdentity( rs, persister.getIdentifierType() ); } }
private static String determineNameOfPropertyToUse(PostInsertIdentityPersister persister, String supplied) { if ( supplied != null ) { return supplied; } int[] naturalIdPropertyIndices = persister.getNaturalIdentifierProperties(); if ( naturalIdPropertyIndices == null ){ throw new IdentifierGenerationException( "no natural-id property defined; need to specify [key] in " + "generator parameters" ); } if ( naturalIdPropertyIndices.length > 1 ) { throw new IdentifierGenerationException( "select generator does not currently support composite " + "natural-id properties; need to specify [key] in generator parameters" ); } ValueInclusion inclusion = persister.getPropertyInsertGenerationInclusions() [ naturalIdPropertyIndices[0] ]; if ( inclusion != ValueInclusion.NONE ) { throw new IdentifierGenerationException( "natural-id also defined as insert-generated; need to specify [key] " + "in generator parameters" ); } return persister.getPropertyNames() [ naturalIdPropertyIndices[0] ]; }
protected void bindParameters( SharedSessionContractImplementor session, PreparedStatement ps, Object entity) throws SQLException { Object uniqueKeyValue = persister.getPropertyValue( entity, uniqueKeyPropertyName ); uniqueKeyType.nullSafeSet( ps, uniqueKeyValue, 1, session ); }
private static String determineNameOfPropertyToUse(PostInsertIdentityPersister persister, String supplied) { if ( supplied != null ) { return supplied; } int[] naturalIdPropertyIndices = persister.getNaturalIdentifierProperties(); if ( naturalIdPropertyIndices == null ){ throw new IdentifierGenerationException( "no natural-id property defined; need to specify [key] in " + "generator parameters" ); } if ( naturalIdPropertyIndices.length > 1 ) { throw new IdentifierGenerationException( "select generator does not currently support composite " + "natural-id properties; need to specify [key] in generator parameters" ); } if ( persister.getPropertyInsertGeneration() [ naturalIdPropertyIndices[0] ] ) { throw new IdentifierGenerationException( "natural-id also defined as insert-generated; need to specify [key] " + "in generator parameters" ); } return persister.getPropertyNames() [ naturalIdPropertyIndices[0] ]; }
protected String getSQL(PostInsertIdentityPersister persister) { return persister.getSelectByUniqueKeyString(uniqueKeyPropertyName); }
@Override public IdentifierGeneratingInsert prepareIdentifierGeneratingInsert() { InsertSelectIdentityInsert insert = new InsertSelectIdentityInsert( dialect ); insert.addIdentityColumn( persister.getRootTableKeyColumnNames()[0] ); return insert; }
public Serializable executeAndExtract(PreparedStatement insert) throws SQLException { insert.executeUpdate(); ResultSet rs = null; try { rs = insert.getGeneratedKeys(); return IdentifierGeneratorHelper.getGeneratedIdentity( rs, persister.getIdentifierColumnNames()[0], persister.getIdentifierType() ); } finally { if ( rs != null ) { rs.close(); } } } }
protected Serializable getResult(SessionImplementor session, ResultSet rs, Object object, PostInsertIdentityPersister persister) throws SQLException { return IdentifierGeneratorFactory.getGeneratedIdentity( rs, persister.getIdentifierType() ); } }
private static String determineNameOfPropertyToUse(PostInsertIdentityPersister persister, String supplied) { if ( supplied != null ) { return supplied; } int[] naturalIdPropertyIndices = persister.getNaturalIdentifierProperties(); if ( naturalIdPropertyIndices == null ){ throw new IdentifierGenerationException( "no natural-id property defined; need to specify [key] in " + "generator parameters" ); } if ( naturalIdPropertyIndices.length > 1 ) { throw new IdentifierGenerationException( "select generator does not currently support composite " + "natural-id properties; need to specify [key] in generator parameters" ); } ValueInclusion inclusion = persister.getPropertyInsertGenerationInclusions() [ naturalIdPropertyIndices[0] ]; if ( inclusion != ValueInclusion.NONE ) { throw new IdentifierGenerationException( "natural-id also defined as insert-generated; need to specify [key] " + "in generator parameters" ); } return persister.getPropertyNames() [ naturalIdPropertyIndices[0] ]; }
protected void bindParameters( SessionImplementor session, PreparedStatement ps, Object entity) throws SQLException { Object uniqueKeyValue = persister.getPropertyValue( entity, uniqueKeyPropertyName ); uniqueKeyType.nullSafeSet( ps, uniqueKeyValue, 1, session ); }
@Override protected Serializable executeAndExtract(PreparedStatement insert, SharedSessionContractImplementor session) throws SQLException { session.getJdbcCoordinator().getResultSetReturn().executeUpdate( insert ); return IdentifierGeneratorHelper.getGeneratedIdentity( insert.getGeneratedKeys(), getPersister().getRootTableKeyColumnNames()[0], getPersister().getIdentifierType(), session.getJdbcServices().getJdbcEnvironment().getDialect() ); } }
private SelectGeneratorDelegate( PostInsertIdentityPersister persister, Dialect dialect, String suppliedUniqueKeyPropertyName) { super( persister ); this.persister = persister; this.dialect = dialect; this.uniqueKeyPropertyName = determineNameOfPropertyToUse( persister, suppliedUniqueKeyPropertyName ); idSelectString = persister.getSelectByUniqueKeyString( uniqueKeyPropertyName ); uniqueKeyType = persister.getPropertyType( uniqueKeyPropertyName ); idType = persister.getIdentifierType(); }
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 Serializable executeAndExtract(PreparedStatement insert) throws SQLException { insert.executeUpdate(); return IdentifierGeneratorHelper.getGeneratedIdentity( insert.getGeneratedKeys(), getPersister().getIdentifierColumnNames()[0], getPersister().getIdentifierType() ); } }