Use of HiLoGenerator with sql-util DAO classes
Add table ID_GENERATOR to TableDefinitions
TableInfo idGenerator=new TableInfo("ID_GENERATOR");idGenerator.setColumns(Arrays.asList( new ColumnInfo("NEXT_ID",Types.BIGINT,20,null,false,null))); |
Future versions should use the constants HiLoIdGenerator.DEFAULT_ID_TABLE_NAME, HiLoIdGenerator.DEFAULT_NEXT_ID_COL_NAME which are part of sql-util as of the yet unreleased version 1.2.1.
Instantiate an idGenerator bean
init-method="initialize" depends-on="databaseSetup"></bp:bean> |
databaseSetup is the bean representing the JDBC2XML SchemaManager (see this HowTo), depends-on assures, that the ID generator is started after the database tables are set up.
Variant: idGeneratorbean using application specific table and column names:
init-method="initialize" depends-on="databaseSetup"> <!-- idTableName, default: ID_GENERATOR --> <!-- nextIdColumnName, default: NEXT_ID --></bp:bean> |
Set the sqlGenerator in your DAOs
</bp:bean> |
, multiple selections available,