openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Henno Vermeulen <>
Subject repeatable autogenerate names for key constraints
Date Mon, 22 Apr 2013 11:27:35 GMT
When I let OpenJPA generate my database schema on sql server, the generated foreign keys have
names such as


When I later generate the schema again I get different names, e.g.


I use a database schema comparison tool to create a migration script for a newer version of
my application. Because of the different names it lists very many changes that are not really
changes at all.

Is it possible to let OpenJPA automatically generate the same names for the same primary/foreign
keys? Perhaps it is possible to override the default strategy with a few lines of Java code?
Is there another approach you can suggest?

All of my entities inherit an autogenerated primary key from a single mapped superclass.

PS. I know of the @ForeignKey annotation but it has a few drawbacks:

-          adds unnecessary boilerplate code (name can be autogenerated without numbers) that
takes time to maintain.

-          Not sure if it works for mappings such as element collections and Maps

-          Obviously won't work for primary keys, especially not if it is defined in one place
in a mapped superclass

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