dev@glassfish.java.net

Re: Mapping one colunm in two foreign keys

From: Gordon Yorke <gordon.yorke_at_oracle.com>
Date: Fri, 19 Dec 2008 08:59:34 -0400

This is because you have marked the columns as not updatable and not
insertable. (insertable = false, updatable = false) TopLink will not
write values to columns you have configured to not be writable, that
would violate your configuration and no doubt raise SQL exceptions.
These columns must be marked as writable if you wish TopLink to write to
them.
--Gordon

Guilherme Namen Pimenta wrote:
> Hello.
> Could someone help me to implement mappgin one column in two foreign
> keys.
> To be more especifc i want to implemet this kind of relationship:
>
> @JoinColumns({
> @JoinColumn(name = "CDPAIS", referencedColumnName = "CDPAIS",
> insertable = false, updatable = false),
> @JoinColumn(name = "SGESTADO", referencedColumnName =
> "SGESTADO",
> insertable = false, updatable = false),
> @JoinColumn(name = "CDMUNICIPIO", referencedColumnName =
> "CDMUNICIPIO", insertable = false, updatable = false),
> @JoinColumn(name = "CDBAIRRO", referencedColumnName =
> "CDBAIRRO")})
> @ManyToOne(fetch = FetchType.LAZY)
> private Bairro bairro;
>
> @JoinColumns({
> @JoinColumn(name = "CDPAIS", referencedColumnName = "CDPAIS",
> insertable = false, updatable = false),
> @JoinColumn(name = "SGESTADO", referencedColumnName =
> "SGESTADO")})
> @ManyToOne(fetch = FetchType.LAZY)
> private Estado estado;
>
> @JoinColumns({
> @JoinColumn(name = "CDPAIS", referencedColumnName = "CDPAIS",
> insertable = false, updatable = false),
> @JoinColumn(name = "SGESTADO", referencedColumnName =
> "SGESTADO",
> insertable = false, updatable = false),
> @JoinColumn(name = "CDMUNICIPIO", referencedColumnName =
> "CDMUNICIPIO")})
> @ManyToOne(fetch = FetchType.LAZY)
> private Municipio municipio;
>
> @JoinColumn(name = "CDPAIS", referencedColumnName = "CDPAIS")
> @ManyToOne(fetch = FetchType.LAZY)
> private Pais pais;
>
> TopLink can't generete correct insert an update sql setence for this
> mapping, it simple ignores the municipio, estado and bairro.
> Thanks
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>