Presentation on theme: "WaveMaker Visual AJAX Studio 4.0 Training"— Presentation transcript:
1 WaveMaker Visual AJAX Studio 4.0 Training Basics: Building Your First ApplicationDatabase Basics
2 Building your First Application Define Data2. Build GUI3. Bind data to GUIImport data in Live TablesDrag-n-drop widgets in Page DesignerConnect data to widgets in Page DesignerCan deploy app to any Java serverCan also import Java and Web Services** Steps 1 and 2 can be reversed – you can design first then add data
3 Define DataDatabase TerminologyTo access a database in your application, you must import the database schema.Data Model : the representation of a database imported into your WaveMaker project.LiveTable: the representation of a table in your data modelColumns: the representation of the columns in your databaseRelationships: the representation of the foreign key relationships from your database
4 Define DataSupported DatabasesAll databases that are supported by Hibernate are supported in WaveMakerBuilt-in Support:PostGreSQLMySQLOracleDB2SQL ServerHypersonic SQL DB (HSQLDB)
5 How to Import a Database Define DataHow to Import a DatabaseOn the Create & Import menu -> Select Database Import…Opens the Import Database editorEnter settingsClick Test ConnectionIf successful, click ImportSave the project
6 Connection Parameters Define DataConnection ParametersSome fields are dependent on type of database importedService Name – name of the data model in WaveMaker, can be same as database name, alphanumeric characters onlyUsername – login name for databasePassword – corresponding password for usernameDatabase System – select type of databaseHost – network host for database, default is localhostPort – port number to connect to databaseDatabase – name of database to importFile – location of HSQLBD database on file systemSID – Oracle System Identifier, instance of Oracle running on the serverInstance – name of SQL server instanceBe sure to give your new data model a good human readable name (In the Service Name field)Different databases require different connection settingsDB2When you import a DB2 database, you will need to type the following settings into the “Database Connection” screen:Database System: The type of database you want to import. Choose DB2.Host: The network host for the DB2database. Default value is localhost.Port: The port number for the DB2 database.Database: The name of the database.HSQLDBWhen you import an HSQLDB database, you will need to type the following settings into the “Database Connection” screen:Database System: The type of database you want to import. Choose HSQLDB.File: The location of the HSQLDB database on your file system. For example, if your database file is called cmdb and it is in C:\Program Files\WaveMaker, then you would type in: C:\Program Files\WaveMaker\Support\Data\cmdb\cmdbMySQLWhen you import a MySQL database, you will need to type the following settings into the “Database Connection” screen:Database System: The type of database you want to import. Choose MySQL.Host: The network host for the MySQL database. Default value is localhost.Port: The port number for the MySQL database.Database: The name of the database instance.OracleWhen you import an Oracle database, you will need to type the following settings into the “Database Connection” screen:Database System: The type of database you want to import. Choose Oracle.Host: The network host for the Oracle database. Default value is localhost.Port: The port number for the Oracle database.SID: The Oracle System Identifier that refers to the instance of the Oracle database running on the server. The default is ORCL, which is the default SID that is configured when installing your Oracle database.PostgreSQLWhen you import a PostgreSQL database, you will need to type the following settings into the “Database Connection” screen:Database System: The type of database you want to import. Choose PostgreSQL.Host: The network host for the PostgreSQL database. Default value is localhost.Port: The port number for the PostgreSQL database.SQL ServerWhen you import a SQL Server database, you will need to type the following settings into the “Database Connection” screen:Database System: The type of database you want to import. Choose SQLServer.Host: The network host for the SQL Server database. Default value is localhost.Port: The port number for the SQL Server database.Instance: The name of the SQL Server instance.
7 Define DataAdvanced OptionsUsed when connection to large databases or connecting to an non-support databaseConnection URL – JDBC connection URLJava Package – Change the default package name for auto generated classesTable Filter – Use to import a subset of tablesSchema Filter – Only default schema will be imported, use to import other schemasDriver Class – JDBC driver class name, change to use a different jar file name for importDialect – Java class name used to map SQL names for Hibernate
8 Testing your connection Define DataTesting your connectionTest Connection – use to verify connection parametersImport – imports the database into WaveMaker, can take several minutes depending on size of databaseClose – closes the settings dialog box without importing the databaseBe sure to always test your connect before importing to verify your connection parameters.Import – actually queries the database created
9 Define DataWhat are LiveTables?All of the data models available to your application are listed in the tree on the left side of the LiveTables editorUnder each data model, all of the LiveTables for that model are listedLiveTable is just a fancy name for a table in which WM has automated producing CRUD functionalitySelect a LiveTable to see its details in the right side of the editor
10 Managing LiveTables New – creates a new table in the data model Define DataManaging LiveTablesNew – creates a new table in the data modelDelete – removes a table from the data modelNew and Delete table only affect the data model and do not change the underlying database unless exportedImport Database – brings up the Import Database dialog box to import a new databaseConnection Settings – brings up dialog box to which allows you to manage the connections to all of the databases used by this application.
11 Managing Database Connection Settings Define DataManaging Database Connection SettingsConnection settings for all databases can be accessed through one dialog boxSave – save changed settingsRe-Import – overwrites data modelExport – pushes data model to database. BE CAREFUL WHEN USING THIS OPTION AS IT WILL DROP AND RECREATE THE TARGET SCHEMA – DATA WILL BE LOST!Will cover exporting in further detail later in this chapter
12 Re-importing a Database Define DataRe-importing a DatabaseRecommended that database changes be made on the database and changes be re-importedMinor changes should be handled appropriate through the application.Relationships,Addition or deletion of a tables, columnsIf major changes are made you may need to check functionality within the application to make sure things still work correctly.Changing column names and relationships
13 Define DataExporting a DatabaseExporting a data model from WaveMaker to your database is possibleThis is recommended for test or new databases onlyAll tables are dropped and recreatedYou will lose data!
14 General Settings Define Data Save – any changes made in this editor must be saved using this iconDatabase – value is dependent on type of database system, generally refers to name space that contains the tablePackage – Java package name of the data model, if changed will affect all LiveTables in that data modelTable Name – table name in the database that the LiveTable referencesEntity Name – name of the LiveTableAll of these fields can be edited
15 General Settings Define Data Dynamic Insert – if checked, SQL statement sent by WaveMaker to the database does not include empty fieldsDynamic Update – if checked, columns that have null values are excluded from SQL update statementsDynamic Insert and Dynamic Update map directly to the Hibernate settings dynamic-insert and dynamic-update.Refresh Entity – if checked, a SQL select statement is run to fetch the row just inserted or updated to include any fields that are set by the underlying database (Example: Date Time Stamps)Dynamic Insert: In WaveMaker Studio, by default, the SQL statement for an insert includes all columns, assigning a null value to any field that doesn’t have a value. When you do an “insert” operation, all empty fields are inserted with “null” values, even if the column has a default value. To get default values to work, check the Dynamic Insert check box. When Dynamic Insert is turned on, the SQL statement that WaveMaker Studio sends to the database does not include empty fields.Dynamic Update: In WaveMaker Studio, by default, the SQL statement for an update includes all columns, assigning a null value to any field that doesn’t have a value. Depending on how the database handles this, fields with existing values might be updated to have a null value. If the Dynamic Insert check box is checked, then columns that have null values are excluded from the SQL update statements.Refresh Entity: Checking Refresh Entity means that we will do a select after each insert and update. If you have default values for insert (like current date), or a trigger that runs on update, then after an insert or update the values in your database will be different than the values we have in memory. In some cases this is not a problem, since the in-memory values will just be thrown away. But if you want to display the database-generated values on the client, you need to select Refresh Entity.When Refresh Entity is selected, we run a SQL select statement to fetch the row you just inserted or deleted. We then update the in-memory values with the ones returned by the SQL select. This option is unchecked by default because of the performance cost of doing a select after every insert or update.NOTE: A database-generated primary key is always returned to the client after an insert. You do not need to select Refresh Entity to get that.NOTE: Dynamic Insert and Dynamic Update map directly to the Hibernate settings dynamic-insert and dynamic-update.
16 Managing Column’s Define Data Add – adds a column Delete – remove selected columnName – column namePrimary Key – if checked, column is the primary key, can only have 1 primary key per LiveTableForeign Key – true or falseType – column data typeNot Null – if checked, column cannot hold null valueIn the tree, the PK field is represented with a *
17 Managing Columns Define Data Length – maximum number of characters in columnPrecision - maximum number of digits used, only for numeric data typesGenerator – if the column is a primary key, specifies the method of key generationAssigned, identity, sequence, nativeParams – if a generator is selected, specifies the parameters for that generator, if anyGenerator types:assigned lets the application assign an identifier to the object before save() is called. This is the default strategy if no <generator> element is specified.identity supports identity columns in DB2, MySQL, MS SQL Server, Sybase and HypersonicSQL. The returned identifier is of type long, short or int.sequence uses a sequence in DB2, PostgreSQL, Oracle, SAP DB, McKoi or a generator in Interbase. The returned identifier is of type long, short or intnative picks identity, sequence or hilo depending upon the capabilities of the underlying database
18 Managing Relationships Define DataManaging RelationshipsAdd – create a relationship to another LiveTableDelete – remove an existing relationshipName – relationship nameRelated Type – LiveTable referencedCardinality – to-many or to-oneTable Name – name of table in database referencedColumn Names – column in LiveTable that is relatedCascade Options – method to push changes from masterRelationships can be added at the model level and not exported back in the case where the underlying data model does not have the needed relationships definedIn the tree, left angle bracket (<) represents one to many relationshipIn the tree, right angle bracket (>) represents one to one relationshipCascade Options – none, save-update, persist, merge, delete, remove, lock, replicate, evict, refresh, delete-orphan, all