tags:

views:

307

answers:

1

I am using Hibernate 3 with Oracle 10.

Is there a way to specify in a Hibernate mapping file the constraint names (from foreign keys, unique constraints, etc) that will be created rather than the (not user-friendly) generated ones?

A: 

I've used the unique-key="name of constraint" syntax successfully with Oracle before. There is also a property called foreign-key on many-to-one that I assume does the same thing (although the documentation doesn't say).

For example, I know this works for unique constraints:

<many-to-one name="column1" class="Class1" unique-key="TABLE_U1"/>
<property name="column2" unique-key="TABLE_U1" />

I assume this would work for the foreign key:

<many-to-one name="column1" class="Class1" foreign-key="TABLE_FK1"/>
Brian Deterling