You are viewing an old version of this page. View the current version.
Compare with Current
View Page History
Version 1
Current »
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 )
));
|
Instantiate an idGenerator bean
<bp:bean id= "idGenerator" class = "org.clazzes.util.sql.dao.HiLoIdGenerator" init-method= "initialize" depends-on= "databaseSetup" >
|
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: idGenerator bean using application specific table and column names:
<bp:bean id= "idGenerator" class = "org.clazzes.util.sql.dao.HiLoIdGenerator" init-method= "initialize" depends-on= "databaseSetup" >
<!-- idTableName, default : ID_GENERATOR -->
<bp:property name= "idTableName" value= "MYAPP_ID_GENERATOR" /> <!-- nextIdColumnName, default : NEXT_ID -->
|
Set the IdGenerator in your DAOs
<bp:bean id= "userDAO" class = "at.egv.drust.impl.dao.jdbc.DsUserJdbcDAO" > |