Daobab Reverse Engineering

How to create ORM classes and begin having fun with Daobab.

Prepare DataSource

    private DataSource oracleDatabase(){
        HikariConfig config = new HikariConfig();
        config.setJdbcUrl( "jdbc:oracle:thin://@IP:PORT/orcl" );
        config.setUsername( USER );
        config.setPassword( PASS );
        config.setDriverClassName("oracle.jdbc.OracleDriver");
        config.setSchema(SCHEMA);
        return new HikariDataSource( config );
    }

Init Class Generator and set schema

ClassGenerator cg=new ClassGenerator(oracleDatabase());
cg.setSchema("myschema");

Set classes location and java package

cg.setJavaPackage("com.company.dao");
cg.setFileDirectoryPath("C:\\project\\src\\main\\java\\com\\company\\dao");
cg.createTables();
        

Execute generator.
Generator creates schema package with column and table packages inside. DataBaseTarget as database connector will be created as well.

Copy DataSource to created DataBaseTarget class.
DataSource conenction is your code. You should controll the behaviour, setting pooling for example (and you may choose HikariCP or CP30 for that).

Make DataBaseTarget singleton
This is framework based behaviour.

Inject DataSource and your schema tables anywhere where you want to build daobab queries