|
General¶
What is OpenJPA?¶OpenJPA is a 100% open-source implementation of the Java Persistence API (JPA), which is the persistence component for EJB in the Java EE 5 specification . What is the history of OpenJPA?¶OpenJPA has its roots in the popular Kodo product, which was created by SolarMetric, Inc. in 2001. BEA Systems, Inc. purchased SolarMetric in November of 2005, and soon thereafter announced that they would be donating the bulk of the code to the Apache Software Foundation. OpenJPA is the result of that donation. What is the current relationship between Kodo and OpenJPA?¶Version 4.1 of Kodo will be based on the OpenJPA code base. What is the current status of the project?¶OpenJPA is a top-level project at the Apache Software Foundation. Where can I download OpenJPA?¶Look at the Downloads page. Does OpenJPA work with my application server or container?¶See Integration . How can I contribute to OpenJPA?¶Check out the Get Involved page. How do I figure out which version of OpenJPA I am running?¶You can get version number and other details of OpenJPA jar you are using by: How do I see the SQL that OpenJPA is executing?¶OpenJPA provides configurable channel-based logging, as described in the chapter on Logging . The simplest example of enabling verbose logging is by using the following property in your {{persistence.xml}} file:
transaction-type="RESOURCE_LOCAL">
As of the 2.1.0 release, OpenJPA includes the Apache DBCP connection pool. You can also use any third-party connection pool that is configurable via the JDBC DataSource API (which most are). The following persistence.xml example shows how to use OpenJPA with a [Apache Derby|http://db.apache.org/derby/] database and the [Apache DBCP|http://jakarta.apache.org/commons/dbcp/] connection pool:
See the documentation on Using a Third-Party DataSource for further details. Can OpenJPA reorder SQL statements to satisfy database foreign key constraints?¶Yes. OpenJPA can reorder and/or batch the SQL statements using different configurable strategies. The default strategy is capable of reordering the SQL statements to satisfy foreign key constraints. However ,you must tell OpenJPA to read the existing foreign key information from the database schema:
See the documentation on Schema Factory for further details. Why OpenJPA is not creating foreign key constraints on the database tables?¶By default, OpenJPA does not create foreign key constraints on new tables that gets created according to O-R mapping annotation/descriptors. You can change this default behavior via following configuration property :
to create foreign key constraints on the database tables generated by OpenJPA. Can OpenJPA map a one-sided one-many association without a cross table?¶Yes. Standard JPA specification use a cross table to map one-sided one-to-many relation without a {{mappedBy}} inverse side. Often, you would like to create a one-to-many association based on an inverse foreign key (logical or actual) in the table of the related type. OpenJPA supports this mapping via {{@ElementJoinColumn}} annotation. The following example will map the collection of {{LineItem}} of a {{Subscription}} via a foreign key of {{LINEITEM}} table referring to primary key of {{SUBSCRIPTION}} table. {code:JAVA} package org.mag.subscribe;
|