I am trying to update to hibernate 3.5.3 with spring 3.0.2
One issue I am having is that the IdentifierGeneratorFactory.class has changed in the hibernate-core jar. Looks as if the the class was moved into a factory package. The getGeneratedIdentity() method isn't there anymore. We were using IdentifierGeneratorFactory.getGeneratedIdentity() is retrieve the id generated after the record update
Code:
public class TriggerAssignedIdentityGenerator extends AbstractPostInsertGenerator {
public InsertGeneratedIdentifierDelegate getInsertGeneratedIdentifierDelegate(
final PostInsertIdentityPersister persister, final Dialect dialect,
final boolean isGetGeneratedKeysEnabled)
throws HibernateException {
return new Delegate(persister, dialect);
}
public static class Delegate extends AbstractReturningDelegate {
private final Dialect dialect;
private final String[] keyColumns;
public Delegate(final PostInsertIdentityPersister persister,
final Dialect dialect) {
super(persister);
this.dialect = dialect;
this.keyColumns = getPersister().getRootTableKeyColumnNames();
if (keyColumns.length > 1) {
throw new HibernateException(
"trigger assigned identity generator cannot be used with multi-column keys");
}
}
public IdentifierGeneratingInsert prepareIdentifierGeneratingInsert() {
return new NoCommentsInsert(dialect);
}
protected PreparedStatement prepare(final String insertSQL,
final SessionImplementor session) throws SQLException {
return session.getBatcher().prepareStatement(insertSQL, keyColumns);
}
protected Serializable executeAndExtract(final PreparedStatement insert)
throws SQLException {
insert.executeUpdate();
return IdentifierGeneratorFactory.getGeneratedIdentity(insert.getGeneratedKeys(), getPersister()
.getIdentifierType());
}
}
Now that hibernate 3.5.x has dropped the getGeneratedIdentity() from the IdentifierGeneratorFactory.class, how can I retrieve the id generatored keys after the update?