These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 
Author Message
 Post subject: IllegalArgumentException on session.save() with composite-id
PostPosted: Thu Dec 09, 2004 7:11 am 
Newbie

Joined: Thu Dec 09, 2004 6:27 am
Posts: 5
Location: Indaiatuba/SP - Brasil
Hi, when carrying through session.save(funcionario) I have following exception: (text from log4j)
ERROR net.sf.hibernate.property.BasicPropertyAccessor - IllegalArgumentException in class: br.com.atmtec.main.bo.pk.FuncionarioPk, getter method of property: codEmp
I am postando therefore I did not find nobody that had passed for the same problem.
Thanks for attention.

Hibernate version:
2.1.7c

Mapping documents:
Code:
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping
>
    <class
        name="br.com.atmtec.main.bo.Funcionario"
        table="funcionario"
        dynamic-update="false"
        dynamic-insert="false"
        select-before-update="false"
    >

        <composite-id
            name="id"
            class="br.com.atmtec.main.bo.pk.FuncionarioPk"
        >
                     <key-property
                        name="codEmp"
                        type="java.lang.String"
                        column="fu_emp_res"
                />

                     <key-property
                        name="codigo"
                        type="java.lang.String"
                        column="fu_cod_fun"
                />

        </composite-id>

        <property
            name="cep"
            type="java.lang.String"
            update="true"
            insert="true"
            access="property"
            column="fu_cep"
        />

        <property
            name="comissao"
            type="java.lang.Float"
            update="true"
            insert="true"
            access="property"
            column="fu_comissao"
        />

        <property
            name="complBairro"
            type="java.lang.String"
            update="true"
            insert="true"
            access="property"
            column="fu_com_bairro"
        />

        <property
            name="email"
            type="java.lang.String"
            update="true"
            insert="true"
            access="property"
            column="fu_e_mail"
        />

        <property
            name="endereco"
            type="java.lang.String"
            update="true"
            insert="true"
            access="property"
            column="fu_endereco"
        />

        <property
            name="estado"
            type="java.lang.String"
            update="true"
            insert="true"
            access="property"
            column="fu_estado"
        />

        <property
            name="identificacao"
            type="java.lang.String"
            update="true"
            insert="true"
            access="property"
            column="fu_identif"
        />

        <property
            name="municipio"
            type="java.lang.String"
            update="true"
            insert="true"
            access="property"
            column="fu_municipio"
        />

        <property
            name="nome"
            type="java.lang.String"
            update="true"
            insert="true"
            access="property"
            column="fu_nom_fun"
        />

        <property
            name="telefone"
            type="java.lang.String"
            update="true"
            insert="true"
            access="property"
            column="fu_telefone"
        />

        <property
            name="tipo"
            type="java.lang.String"
            update="true"
            insert="true"
            access="property"
            column="fu_tip_fun"
        />

        <component
            name="trilha"
            class="br.com.atmtec.main.bo.TrilhaAudt"
        >
        <property
            name="data_alt"
            type="java.util.Date"
            update="true"
            insert="true"
            access="property"
            column="fu_data_alt"
        />

        <property
            name="data_inc"
            type="java.util.Date"
            update="true"
            insert="true"
            access="property"
            column="fu_data_inc"
        />

        <property
            name="hora_alt"
            type="java.lang.String"
            update="true"
            insert="true"
            access="property"
            column="fu_hora_alt"
        />

        <property
            name="hora_inc"
            type="java.lang.String"
            update="true"
            insert="true"
            access="property"
            column="fu_hora_inc"
        />

        <property
            name="user_alt"
            type="java.lang.String"
            update="true"
            insert="true"
            access="property"
            column="fu_user_alt"
        />

        <property
            name="user_inc"
            type="java.lang.String"
            update="true"
            insert="true"
            access="property"
            column="fu_user_inc"
        />

        </component>

        <!--
            To add non XDoclet property mappings, create a file named
                hibernate-properties-Funcionario.xml
            containing the additional properties and place it in your merge dir.
        -->

    </class>

        <query name="func.list"><![CDATA[
            from br.com.atmtec.main.bo.Funcionario func where func.id.codEmp = :cod_emp
        ]]></query>

</hibernate-mapping>



Code:
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping
>
    <class
        name="br.com.atmtec.main.bo.Empresa"
        table="empresa"
        dynamic-update="false"
        dynamic-insert="false"
        select-before-update="false"
    >

        <id
            name="codigo"
            column="em_cod_emp"
            type="java.lang.String"
            unsaved-value="any"
        >
            <generator class="assigned">
              <!-- 
                  To add non XDoclet generator parameters, create a file named
                  hibernate-generator-params-Empresa.xml
                  containing the additional parameters and place it in your merge dir.
              -->
            </generator>
        </id>

        <property
            name="descricao"
            type="java.lang.String"
            update="true"
            insert="true"
            access="property"
            column="em_des_emp"
        />

        <property
            name="numPosCpfCnpj"
            type="java.lang.Float"
            update="true"
            insert="true"
            access="property"
            column="em_pos_cod_cli"
        />

        <property
            name="toleranciaDia"
            type="java.lang.Float"
            update="true"
            insert="true"
            access="property"
            column="em_tol_dia_atr"
        />

        <property
            name="toleranciaMax"
            type="java.lang.Float"
            update="true"
            insert="true"
            access="property"
            column="em_tol_max_atr"
        />

        <property
            name="verificador"
            type="java.lang.String"
            update="true"
            insert="true"
            access="property"
            column="em_ver_dig"
        />

        <many-to-one
            name="moeda"
            class="br.com.atmtec.main.bo.Moeda"
            cascade="none"
            outer-join="auto"
            update="false"
            insert="false"
            access="property"
        >
            <column
                name="em_moe_cor"
            />
            <column
                name="emp_res"
            />
        </many-to-one>

        <component
            name="trilha"
            class="br.com.atmtec.main.bo.TrilhaAudt"
        >
        <property
            name="data_alt"
            type="java.util.Date"
            update="true"
            insert="true"
            access="property"
            column="data_alt"
        />

        <property
            name="data_inc"
            type="java.util.Date"
            update="true"
            insert="true"
            access="property"
            column="data_inc"
        />

        <property
            name="hora_alt"
            type="java.lang.String"
            update="true"
            insert="true"
            access="property"
            column="hora_alt"
        />

        <property
            name="hora_inc"
            type="java.lang.String"
            update="true"
            insert="true"
            access="property"
            column="hora_inc"
        />

        <property
            name="user_alt"
            type="java.lang.String"
            update="true"
            insert="true"
            access="property"
            column="user_alt"
        />

        <property
            name="user_inc"
            type="java.lang.String"
            update="true"
            insert="true"
            access="property"
            column="user_inc"
        />

        </component>

        <property
            name="taxaJuro"
            type="java.lang.Float"
            update="true"
            insert="true"
            access="property"
            column="em_tax_juro"
        />

        <!--
            To add non XDoclet property mappings, create a file named
                hibernate-properties-Empresa.xml
            containing the additional properties and place it in your merge dir.
        -->

    </class>

        <query name="emp.list"><![CDATA[
            from br.com.atmtec.main.bo.Empresa
        ]]></query>

</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
Code:
       session = sessionFactory.getSession();
      session.setFlushMode(FlushMode.COMMIT);
      trans = session.beginTransaction();
...
                pk.setCodEmp(funcionario.getId().getCodEmp());
           pk.setCodigo(funcionario.getId().getCodigo());
                funcionario.setId(pk);
                dao.save(funcionario);
...
                sessionFactory.getSession().save(obj);
...
                trans.commit();


Full stack trace of any exception that occurs:
none

Name and version of the database you are using:
postgresql 7.4.3

Debug level Hibernate log excerpt:
Code:
16:35:07,399 DEBUG SessionImpl:555 - opened session
33208 [http-8080-Processor24] DEBUG net.sf.hibernate.impl.SessionImpl  - opened session
16:35:07,399 DEBUG SessionImpl:1982 - loading [br.com.atmtec.main.bo.Funcionario#000001]
33208 [http-8080-Processor24] DEBUG net.sf.hibernate.impl.SessionImpl  - loading [br.com.atmtec.main.bo.Funcionario#000001]
16:35:07,399 DEBUG SessionImpl:2079 - attempting to resolve [br.com.atmtec.main.bo.Funcionario#000001]
33208 [http-8080-Processor24] DEBUG net.sf.hibernate.impl.SessionImpl  - attempting to resolve [br.com.atmtec.main.bo.Funcionario#000001]
16:35:07,419 DEBUG SessionImpl:2112 - object not resolved in any cache [br.com.atmtec.main.bo.Funcionario#000001]
33228 [http-8080-Processor24] DEBUG net.sf.hibernate.impl.SessionImpl  - object not resolved in any cache [br.com.atmtec.main.bo.Funcionario#000001]
16:35:07,419 DEBUG EntityPersister:416 - Materializing entity: [br.com.atmtec.main.bo.Funcionario#000001]
33228 [http-8080-Processor24] DEBUG net.sf.hibernate.persister.EntityPersister  - Materializing entity: [br.com.atmtec.main.bo.Funcionario#000001]
16:35:07,429 DEBUG BatcherImpl:196 - about to open: 0 open PreparedStatements, 0 open ResultSets
33238 [http-8080-Processor24] DEBUG net.sf.hibernate.impl.BatcherImpl  - about to open: 0 open PreparedStatements, 0 open ResultSets
16:35:07,429 DEBUG SQL:237 - select funcionari0_.fu_emp_res as fu_emp_res0_, funcionari0_.fu_cod_fun as fu_cod_fun0_, funcionari0_.fu_cep as fu_cep0_, funcionari0_.fu_comissao as fu_comis4_0_, funcionari0_.fu_com_bairro as fu_com_b5_0_, funcionari0_.fu_e_mail as fu_e_mail0_, funcionari0_.fu_endereco as fu_ender7_0_, funcionari0_.fu_estado as fu_estado0_, funcionari0_.fu_identif as fu_identif0_, funcionari0_.fu_municipio as fu_muni10_0_, funcionari0_.fu_nom_fun as fu_nom_fun0_, funcionari0_.fu_telefone as fu_tele12_0_, funcionari0_.fu_tip_fun as fu_tip_fun0_, funcionari0_.fu_data_alt as fu_data14_0_, funcionari0_.fu_data_inc as fu_data15_0_, funcionari0_.fu_hora_alt as fu_hora16_0_, funcionari0_.fu_hora_inc as fu_hora17_0_, funcionari0_.fu_user_alt as fu_user18_0_, funcionari0_.fu_user_inc as fu_user19_0_ from data.funcionario funcionari0_ where funcionari0_.fu_emp_res=? and funcionari0_.fu_cod_fun=?
33238 [http-8080-Processor24] DEBUG net.sf.hibernate.SQL  - select funcionari0_.fu_emp_res as fu_emp_res0_, funcionari0_.fu_cod_fun as fu_cod_fun0_, funcionari0_.fu_cep as fu_cep0_, funcionari0_.fu_comissao as fu_comis4_0_, funcionari0_.fu_com_bairro as fu_com_b5_0_, funcionari0_.fu_e_mail as fu_e_mail0_, funcionari0_.fu_endereco as fu_ender7_0_, funcionari0_.fu_estado as fu_estado0_, funcionari0_.fu_identif as fu_identif0_, funcionari0_.fu_municipio as fu_muni10_0_, funcionari0_.fu_nom_fun as fu_nom_fun0_, funcionari0_.fu_telefone as fu_tele12_0_, funcionari0_.fu_tip_fun as fu_tip_fun0_, funcionari0_.fu_data_alt as fu_data14_0_, funcionari0_.fu_data_inc as fu_data15_0_, funcionari0_.fu_hora_alt as fu_hora16_0_, funcionari0_.fu_hora_inc as fu_hora17_0_, funcionari0_.fu_user_alt as fu_user18_0_, funcionari0_.fu_user_inc as fu_user19_0_ from data.funcionario funcionari0_ where funcionari0_.fu_emp_res=? and funcionari0_.fu_cod_fun=?
16:35:07,429 DEBUG BatcherImpl:241 - preparing statement
33238 [http-8080-Processor24] DEBUG net.sf.hibernate.impl.BatcherImpl  - preparing statement
16:35:07,459 ERROR BasicPropertyAccessor:106 - IllegalArgumentException in class: br.com.atmtec.main.bo.pk.FuncionarioPk, getter method of property: codEmp
33268 [http-8080-Processor24] ERROR net.sf.hibernate.property.BasicPropertyAccessor  - IllegalArgumentException in class: br.com.atmtec.main.bo.pk.FuncionarioPk, getter method of property: codEmp
16:35:07,469 DEBUG BatcherImpl:203 - done closing: 0 open PreparedStatements, 0 open ResultSets
33278 [http-8080-Processor24] DEBUG net.sf.hibernate.impl.BatcherImpl  - done closing: 0 open PreparedStatements, 0 open ResultSets
16:35:07,469 DEBUG BatcherImpl:261 - closing statement
33278 [http-8080-Processor24] DEBUG net.sf.hibernate.impl.BatcherImpl  - closing statement

_________________
Marcelo Esperandio


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 09, 2004 11:41 am 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
composite-id can't be name="id" - id is reserved key in hibernate - use another name for property

regards


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 09, 2004 12:41 pm 
Newbie

Joined: Thu Dec 09, 2004 6:27 am
Posts: 5
Location: Indaiatuba/SP - Brasil
Thank you for the help. I made the suggested alteration but the problem continues. Any suggestion is coming well.

_________________
Marcelo Esperandio


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 09, 2004 1:17 pm 
Newbie

Joined: Thu Dec 09, 2004 6:27 am
Posts: 5
Location: Indaiatuba/SP - Brasil
An important detail is that the problem occurred in web environment, using the model of ThreadLocal sessions. To effect the same operation in single thread did not have problem.

_________________
Marcelo Esperandio


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 10, 2004 1:49 pm 
Newbie

Joined: Thu Dec 09, 2004 6:27 am
Posts: 5
Location: Indaiatuba/SP - Brasil
Despite last post, I go to change a little the exposition of my problem. It would like to know if the problem can be being caused for the fact of I not to mapear entities (key-many-to-one) in the composite-id class? I would have to insert this problem in the JIRA?
Please, I appreciate any suggestion.

_________________
Marcelo Esperandio


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 13, 2004 9:32 am 
Newbie

Joined: Thu Dec 09, 2004 6:27 am
Posts: 5
Location: Indaiatuba/SP - Brasil
It will be that this problem is so worthless thus not to have commentaries on it?

_________________
Marcelo Esperandio


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.