persistence@glassfish.java.net

Re: What is wrong in this relationship?

From: Franzisk <francisco.vieira.souza_at_gmail.com>
Date: Tue, 8 Dec 2009 06:51:08 -0800 (PST)

I removed that annotation but it keeps telling that the ID_PARAMETRO which
goes to TABELA_IR is null:

Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs
(12/06/2007))): oracle.toplink.essentials.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Duplicate key or integrity
constraint violation message from server: "Column 'ID_PARAMETRO' cannot be
null"
Error Code: 1048
Call: INSERT INTO TABELA_IR_PARAMETROS (VALOR_BASE_FIM, ALIQUOTA,
VALOR_BASE_INICIO, VALOR_DEDUZIR, ID_PARAMETRO) VALUES (?, ?, ?, ?, ?)
        bind => [5000.0, 11.0, 1000.0, 35.0, null]
Query: InsertObjectQuery([Tabela de IRRF])


Wouter van Reeven wrote:
>
> Hi,
>
>
> You don't need the @JoinColumn in the Parametro.java class.
>
>
> HTH, Wouter
>
> On Tue, Dec 08, 2009 at 06:33:18AM -0800, Franzisk wrote:
>>
>> I have these two Entities, Parametro and TabelaIR, Parametro can have
>> lots of
>> TabelaIR, so I have a 1xN.
>>
>> In Parametro.java I have:
>> @OneToMany(cascade = {CascadeType.ALL}, mappedBy = "parametro", fetch
>> =
>> FetchType.LAZY, targetEntity = TabelaIR.class)
>> @JoinColumn(name = "ID_PARAMETRO")
>> public Collection<TabelaIR> getTabelasIR() {
>> return tabelasIR;
>> }
>>
>> In TabelaIR.java I have:
>> @ManyToOne(cascade = {CascadeType.ALL})
>> @JoinColumn(name = "ID_PARAMETRO", nullable = false)
>> public Parametro getParametro() {
>> return parametro;
>> }
>>
>> The problem is: when persisting the ID_PARAMETRO column in TABELA_IR
>> table
>> is not being saved, it should be set with the ID of of the PARAMETRO
>> table.
>>
>> What is wrong with my ralationship?
>> --
>> View this message in context:
>> http://old.nabble.com/What-is-wrong-in-this-relationship--tp26694802p26694802.html
>> Sent from the java.net - glassfish persistence mailing list archive at
>> Nabble.com.
>
> --
> Gravity brings me down
> [Unknown Source]
>
> Skype: wvreeven
> Facebook: wvreeven
> Twitter: wvreeven
>
>

-- 
View this message in context: http://old.nabble.com/What-is-wrong-in-this-relationship--tp26694802p26695070.html
Sent from the java.net - glassfish persistence mailing list archive at Nabble.com.