How does FireStorm/DAO™ support Oracle sequences?

After you have imported a schema into FireStorm it is possible to enter a "sequence name" for columns where you want FireStorm/DAO™ to automatically set the value of that column based on the specified sequence.

Creating the Oracle sequence

If you do not already have a sequence defined, you can create one using the following Oracle DDL command:

CREATE SEQUENCE [schema.]sequence_name

Sample Java code to use Oracle sequence:

The generated DAO "insert" method will obtain the next value from the sequence before inserting the new row. To use this feature you should use the following programming model.

CustomerDao dao = CustomerDaoFactory.create();
Customer customer = new Customer();
customer.setId( null );
customer.setName( "Andy" );
 
CustomerPk pk = dao.insert( customer);
 
System.out.println( "New customer ID is " + pk.getId() );

Generated Code

The generated DAO implementation code will issue the following SQL code to obtain the next value from the sequence:

SELECT [schema.]sequence_name.NEXTVAL FROM DUAL