Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

134
Vistas
What happens in a SQL database when we use nested JoinColumn in entity

I am going through some code and it uses nested @JoinColumn for one of the associations, as following:

@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinColumns({@JoinColumn(name = "QuestId"), @JoinColumn(name = "GuildId")})
private GuildQuests guildQuest;

I understand that when I do something like the following:

@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinColumns(name="GuildQuestId")
private GuildQuests guildQuest;

I am creating a column with the name GuildQuestId in the table and it has a foreign key constraint with the entity GuildQuests.

However, what will the nested @JoinColumn(first code snippet) do?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Your first snippet is saying that you specify multiple foreign keys for the same association.

Example:

@ManyToOne
@JoinColumns({
    @JoinColumn(name="ADDR_ID", referencedColumnName="ID"),
    @JoinColumn(name="ADDR_ZIP", referencedColumnName="ZIP")
})
public Address getAddress() { return address; }

Edit: You're actually not creating any foreign keys with (both example) in the database. If you use for example Hibernate, Hibernate does not create any foreign keys on database level itself.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda