Setup and Configuration

## 4 Setup and Configuration

Note | The Jakarta EE Specification process provides for any number of compatible implementations. As additional implementations become available, refer to project or product documentation from those vendors for specific TCK setup and operational guidance.

This chapter describes how to set up the Persistence TCK. Before proceeding with the instructions in this chapter, be sure to install all required software, as described in Chapter 3, "Installation."

After completing the instructions in this chapter, proceed to Chapter 5, "Executing Tests," for instructions on running the Persistence TCK.

### 4.1 Configuring Your Environment to Run the TCK Against the Compatible Implementation

Note | In these instructions, variables in angle brackets need to be expanded for each platform. For example, `<JAVA_HOME>` becomes `$JAVA_HOME` on Solaris/Linux and `%JAVA_HOME%` on Windows. In addition, the forward slashes (`/`) used in all of the examples need to be replaced with backslashes (`\`) for Windows. Finally, be sure to use the appropriate separator for your operating system when specifying multiple path entries (`;` on Windows, `:` on UNIX/Linux). On Windows, you must escape any backslashes with an extra backslash in path separators used in any of the following properties, or use forward slashes as a path separator instead.

1. Set the following environment variables in your shell environment:

   1. `JAVA_HOME` to the directory in which Java SE 17+ is installed

   2. `M2_HOME` to the directory in which the Apache Maven build tool is installed.

   3. `ECLIPSELINK_HOME` to the directory in which the Persistence 3.2 CI has been installed

   4. `PATH` to include the following directories: `JAVA_HOME/bin`, and `M2_HOME/bin`

2. set the following system properties:

   1. Set `jpa.classes` to include all of the necessary JAR files that pertain to your implementation using comma separator in the TCK runner.

   2. Set `jdbc.lib.classpath` to the location where the JDBC drivers are installed using comma separator in the TCK runner.

   3. Set `jdbc.driver.classes` to the location where the JDBC drivers are installed using CLASSPATH separator in the TCK runner.

   4. Set `jdbc.db` to the name of the database under test. Valid values include:

          derby
          mysql
          sybase
          db2
          mssqlserver
          oracle
          postgresql

   5. Set `jakarta.persistence.provider`, `jakarta.persistence.jdbc.driver`, `jakarta.persistence.jdbc.url`, `jakarta.persistence.jdbc.user`, and `jakarta.persistence.jdbc.password` to the appropriate values for the database and persistence provider under test.
      These properties are passed to the Persistence provider during the creation of the `EntityManagerFactory`. Any additional values, for example setting an implementation’s logging level, must be set by following the instructions in Step 2e.

   6. Set the `jpa.provider.implementation.specific.properties` property to include any implementation-specific settings that need to be passed to the provider when the `EntityManagerFactory` is created.

   7. Set `sigTestClasspath` to include any additional classes not specified with the `jpa.classes` property.

   8. Set db.supports.sequence to false if the database does not support the use of SEQUENCE.
      The default value is true.

   9. Set `persistence.second.level.caching.supported` to false if your persistence provider does not support second level caching.
      The default value is true.

3. If you are using MySQL or MS SQL Server, do the following:

   1. If you are using MySQL, see Section 4.3.1, "Setup Considerations for MySQL," and proceed to Step 4.

   2. If you are using MS SQL Server, see Section 4.3.2, "Setup Considerations for MS SQL Server," and proceed to Step 4.

4. Start the database under test.

5. Initialize the database under test. Execute following SQL scripts for database initilization:

   1. <jdbc.db>.ddl.persistence.sql

   2. <jdbc.db>.ddl.persistence.sprocs.sql

### 4.2 Configuring Your Environment to Repackage and Run the TCK Against the Vendor Implementation

Note | In these instructions, variables in angle brackets need to be expanded for each platform. For example, `<JAVA_HOME>` becomes `$JAVA_HOME` on Solaris/Linux and `%JAVA_HOME%` on Windows. In addition, the forward slashes (`/`) used in all of the examples need to be replaced with backslashes (`\`) for Windows. Finally, be sure to use the appropriate separator for your operating system when specifying multiple path entries (`;` on Windows, `:` on UNIX/Linux). On Windows, you must escape any backslashes with an extra backslash in path separators used in any of the following properties, or use forward slashes as a path separator instead.

Adapt the instructions above as appropriate for your implementation.

### 4.3 Setup Considerations

### 4.3.1 Setup Considerations for MySQL

The Jakarta Persistence tests require delimited identifiers for the native query tests. If you are using delimited identifiers on MySQL, modify the `sql-mode` setting in the `my.cnf` file to set the ANSI_QUOTES option. After setting this option, reboot the MySQL server. Set the option as shown in this example:

    sql-mode=
        "STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,ANSI_QUOTES"

### 4.3.2 Setup Considerations for MS SQL Server

If your database already exists and if you use a case-sensitive collation on MS SQL Server, execute the following command to modify the database and avert errors caused by case-sensitive collation:

    ALTER DATABASE ctsdb COLLATE Latin1_General_CS_AS ;

Copyright © 2017, 2024 Oracle and/or its affiliates. All rights reserved.