views:

76

answers:

2

There exists a proprietary hibernate annotation to specify the Foreign Key constraint names that are used at DDL generation time: org.hibernate.annotations.ForeignKey.

Is there also a way to specify the Primary Key constraint names?

A: 

If you're talking about choosing the name of your primary key (in the database), Hibernate can not do that.

Remember, Hibernate is a framework that is primarly focused on mapping objects, not on the creation/maintenance of database entities.

With regards to defining the primary key, the following link (particularly 2.2.3.2) might be helpful: Mapping identifier properties in the JBoss Hibernate guide

Marco
True, I do mean the *name* of the PK constraint. Given that there is a mechanism to do it for FK constraints, I was hoping a similar mechanism exists for PK constraints.
Jan
It looks like JDO (http://java.sun.com/jdo/) lets you at least define the name of the index you're using: that's not the same as a primary key, of course. (see http://www.objectdb.com/java/jpa/entity/index#Single_Field_Index)
Marco
+1  A: 

Not possible with standard JPA and not supported by Hibernate for Primary Key constraints neither.

There is actually a very old issue about this feature request (HB-1245) but it looks like it doesn't get much attention.

Pascal Thivent