public void configure(Type type Properties params Dialect d) throws MappingException {
String table = paramsgetProperty(table);
if (table==null) table = paramsgetProperty(PersistentIdentifierGeneratorTABLE);
String column = paramsgetProperty(column);
if (column==null) column = paramsgetProperty(PersistentIdentifierGeneratorPK);
String schema = paramsgetProperty(PersistentIdentifierGeneratorSCHEMA);
sql = select max(+column +) from + ( schema==null ? table : schema + + table );
loginfo(sql);
}
private void getNext(Connection conn) throws HibernateException {
try {
PreparedStatement st = connprepareStatement(sql);
ResultSet rs = stexecuteQuery();
if ( rsnext() ) {
next = rsgetLong() + ;
}
else {
next = l;
}
}catch(SQLException e)
{
throw new HibernateException(e);
}
finally {
try{
connclose();
}catch(SQLException e)
{
throw new HibernateException(e);
}
}
}
}
配置:
在对应的hbm文件里面将id的配置如下:
<id name=
id
type=
long
column=
id
>
<generator class=hibernateIncrementGenerator />
</id>
[] []