openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Dick <michael.d.d...@gmail.com>
Subject Re: Lack of foreign key constraint
Date Fri, 02 Apr 2010 14:05:06 GMT
Hi Jean-Baptiste,

Historically OpenJPA does not create a FK constraint by default. You can
indicate that one should be created by adding the @ForeignKey annotation
(OpenJPA specific) to your entity classes. The schema tool and related tools
will 'manipulate' foreign keys, but I don't remember seeing them create a
FK.

Once you have the FK constraints set up OpenJPA will recognize them if
either of these are true :
* If the annotation is present in your entities
* You've set the Schema Factory to 'native'.

More information in the manual at
http://openjpa.apache.org/builds/latest/docs/manual/manual.html#ref_guide_mapping_jpa_fk
http://openjpa.apache.org/builds/latest/docs/manual/manual.html#ref_guide_schema_info_factory

Hope this helps,
-mike

On Fri, Apr 2, 2010 at 4:15 AM, Jean-Baptiste BRIAUD -- Novlog <
j-b.briaud@novlog.com> wrote:

> Hi,
>
> I just noticed that on the SQL file produced by OpenJPA to install DB
> schema, there are no integrity referential constraints.
> In other words, on relationship, there is no indication that one column is
> a foreign key.
> primary key are there but not foreign keys.
>
> Is it a problem (I didn't found any issue with that before I noticed) ?
> Can I force that to be generated ?
>
> I tested that using MySQL and SqlServer, same behavior : no foreign key
> constraints generated in SQL file.
> I'm using 2.0 beta 2 and will migrate to beta 3 very soon.
>
> Any idea ?
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message