Observações de Mapeamento Hibernate/HBM

Posted About 9 years ago. Visible to the public.

Observações

  • Elemento bag ou set de one-to-many
    • fetch="select" é o padrão, não há necessidade de explicitá-lo, está implícito na ausência de outro fetch
    • Se é fetch="select" também está implícito lazy="false", mas você pode optar por usar lazy="true"
    • Se é fetch="join" não há sentido em utilizar lazy="false" nem lazy="true"
    • Se é inverse="true" não há sentido em utilizar table="nome_tabela"

Exemplos Corretos

fetch="select" lazy="false"

<set name="definicoesEquivalentes" inverse="true">

fetch="select" lazy="true"

<set name="definicoesEquivalentes" inverse="true" lazy="true">

fetch="join"

<set name="definicoesEquivalentes" inverse="true" fetch="join">

Exemplos Escrita Desnecessária

<set name="definicoesEquivalentes" inverse="true" fetch="select">
<set name="definicoesEquivalentes" inverse="true" lazy="false">
<set name="definicoesEquivalentes" inverse="true" fetch="select" lazy="false">
<set name="definicoesEquivalentes" inverse="true" table="nome_tabela">

Exemplos Errados

<set name="definicoesEquivalentes" inverse="true" fetch="join" lazy="true">
<set name="definicoesEquivalentes" inverse="true" fetch="join" lazy="false">
Bruno Vieira
Last edit
About 9 years ago
Bruno Vieira
Posted by Bruno Vieira to ZeroGlosa (2015-03-06 19:13)