Skip to main content
Skip table of contents

JPA Connector

With the JPA connector, you can access all entities used by your deployed web applications on your CData Virtuality Server. By configuring the JPA connector for entities within the web application, you can easily read information from these entities as if you were working with traditional database tables. The functionality of the JPA translator within the CData Virtuality Server is limited to selecting data using SQL and JPA native queries.

Adding a JPA Entity Factory as a Data Source

To configure the JPA connector, follow these steps:

1. Register a desired entityFactory as JNDI in the CData Virtuality Server. For example, if it is a web application, you can register the used entityManager via jboss.entity.manager.factory.jndi.name in its persistence.xml file:

XML
<properties>
<!-- Properties for Hibernate -->
  <property name="hibernate.hbm2ddl.auto" value="create-drop" />
  <property name="hibernate.show_sql" value="false" />
  <property name="jboss.entity.manager.factory.jndi.name" value="java:/testEntityManagerFactory_VDB_ID_1"/>
</properties>

Add the VDB ID using the following template: entityFactory + VDB_ID + ID.

2. Create a JPA data source using the name which was used in JNDI in Step 1:

SQL
CALL "SYSADMIN.createDataSource"(
    "name" => 'testEntityManagerFactory',
    "translator" => 'jpa2',
    "translatorProperties" => 'supportsNativeQueries=true'
);;

Supported Functionality

SQL

You can read data from entities represented as tables using SQL:

SQL
SELECT "key", "value" FROM "testEntityManagerFactory.SimpleProperty";;

Conditions, joins, etc. are also supported.

JPA Native Queries

Alternatively, you can use JPA native queries with a SELECT statement:

SQL
SELECT x.* FROM (CALL testEntityManagerFactory.native('search;FROM SimpleProperty')) w,
 ARRAYTABLE(w.tuple COLUMNS "key" string , "value" string) AS x;;

Limitations

  • A data source cannot be created if one of its entities has columns of any numeric array type;

  • Native queries other than SELECT are not supported;

  • Writing to the data source is not supported.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.