Defining Business Objects that Use Existing Database Tables

To get business objects to use existing database tables or views you need to select the “Database: existing external” option in the “Persistence” drop-down on the business object property editor (see Specifying General Properties). Then you need to provide the following details.

First you need to select the “database environment” that describes how to connect to the existing database. If there are no database environments yet you need to create one by clicking on the Add button next to the “Database” drop down. The details of this process are described later in this section.

After you select the database environment you need to specify the name of the table or view in the existing database that you want to use. Enter the name of the table or view into the “Table or view” text box. Then click on the “Discover Attributes” button. At this point AwareIM will automatically discover all database columns that the specified table or view has and convert them into the corresponding attributes. The results will be displayed in the “Attributes” table. If there are any database columns that could not be converted into attributes AwareIM will display the list of these columns.

If there are any “foreign key constraints” defined for the database table AwareIM will automatically recognize the constraints and create reference attributes corresponding to these constraints. If there are no foreign key contraints defined for the database table but you still want to treat one or more existing columns as foreign keys you can select the corresponding attributes and click on the “Foreign Keys” button. AwareIM will then create a reference attribute to replace the selected attributes.

You should then define a primary key for the table if AwareIM hasn’t recognized one automatically – check the attribute(s) that uniquely identify the record in the database table, for example, a unique id, unique surname, e-mail address etc. If you do not define a primary key AwareIM will be able to perform queries on the business object but will not be able to display individual instances, create new instances or delete the existing ones.

Once the primary key has been defined (automatically or manually) click OK and the discovered attributes will appear in the list of business object attributes. You can now use the business object in the usual way – define queries on the object, business rules, processes etc.

To define a new “database environment” click on the Add button next to the “Database” drop down. This will bring up the “Database environment” dialog. First you need to specify the unique name of your database environment.

Then you need to select the database engine. AwareIM offers several pre-defined database engines to help you specify connection parameters. If your database engine is not among the pre-defined engines you need to select “Custom”.

When you select a particular database engine (a pre-defined one or custom) AwareIM displays connection parameters specific to this database engine. For example, for MySQL database you need to specify MySQL account credentials, machine name where MySQL server is running (if not local machine) and port where MySQL is listening for requests (if not the default one). If you need to specify connection parameters that are not included into this interface you need to select the “Custom” database engine and specify these parameters as part of connection URL string.

When you select the Custom database engine you need to make sure that you have the JDBC driver that allows connections to your database from Java. JDBC drivers exist virtually for all known databases. Many database vendors include JDBC drivers as part of their database offerings. If they don’t you can almost always find a third party JDBC driver. JDBC driver is usually distributed as a file with a .jar extension. You need to put the jar file with the driver into the AwareIM/CustomJars directory (create the directory if needed) and restart AwareIM.

When specifying properties of the Custom connection you need to specify:

  • Fully qualified name of the driver class (check documentation of your JDBC driver)
  • Connection URL string (check documentation of your JDBC driver)