ForeignKey « Annotation « JPA Q&A





1. ForeignKey annotation and indexes    forum.hibernate.org

We are using the @ForeignKey annotation together with @JoinColumn and @ManyToOne to enforce foreign key constraints. Some target databases, such as MySQL, will automatically create an index to enforce the FK constraint (most/all FK constraints are single column). Other databases, e.g. Oracle, do NOT automatically create a FK index. Indexes on FK constraint columns are recommended (improves performance during deletes on ...