I found the answer. It was my fault. Here's what I have, in case
someone else faced the same problem.

>From JPA specs, section "2.4.1.1 Specification of Derived Identities":

============================================================
If an Id attribute in the entity is a many-to-one or one-to-one
relationship to a parent entity, the corresponding attribute in the id
class must be of the same Java type as the
id class or embedded id of the parent entity (if the parent entity has
a composite primary key) or the type of the Id attribute of the parent
entity (if the parent entity has a
simple primary key).
============================================================

In other words, if the entity has a field called "client" and type
"Person" , then in the composite primary key, the filed in the PK
class needs to be called "client", and the type is the same type of
the primary key of the "Person" class. In the case the primary key for
Person.class is String, so client in the composite PK class should be
type String.
Once this is done, we need to add to persistence.xml

            <property name="openjpa.jdbc.MappingDefaults"
value="ForeignKeyDeleteAction=restrict,JoinForeignKeyDeleteAction=restrict"
/>

, as explained in http://openjpa.apache.org/faq.html  (by the way the
anchor at the top of the page is missing  "Why OpenJPA is not creating
foreign key constraints on the database tables?")

The confusing part was that hibernate worked fine with Other object
Types in the PK class !
Anyhow, problem solved (for now).

Reply via email to