| I implemented my own naming strategy:
public class DatamazeImplicitNamingStrategy extends ImplicitNamingStrategyJpaCompliantImpl
{
private static final long serialVersionUID = 1L;
@Override
public Identifier determineForeignKeyName(ImplicitForeignKeyNameSource source)
{
String name = "FK_" + source.getTableName() + "_" + source.getColumnNames()
.stream()
.map(x -> x.toString())
.collect(Collectors.joining("_"));
return toIdentifier(name, source.getBuildingContext());
}
@Override
public Identifier determineIndexName(ImplicitIndexNameSource source)
{
String name = "IX_" + source.getTableName() + "_" + source.getColumnNames()
.stream()
.map(x -> x.toString())
.collect(Collectors.joining("_"));
return toIdentifier(name, source.getBuildingContext());
}
@Override
public Identifier determineUniqueKeyName(ImplicitUniqueKeyNameSource source)
{
String name = "UK_" + source.getTableName() + "_" + source.getColumnNames()
.stream()
.map(x -> x.toString())
.collect(Collectors.joining("_"));
return toIdentifier(name, source.getBuildingContext());
}
}
but I can't get it called when using @Column/@JoinColumn with unique=true. The resulting constraint/index SQL statement is always something like
alter table ASSET add constraint UK_88x4vo88ix1k9jnovcylc55t9 unique (SYSTEM_NODE_ID)
when I expect
alter table ASSET add constraint UK_ASSET_SYSTEM_NODE_ID unique (SYSTEM_NODE_ID)
Let me know if you need a test-case (this is far too simple to verify). |