Announcement Announcement Module
Collapse
No announcement yet.
Problem with hibernate batch (a bit urgent) Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem with hibernate batch (a bit urgent)

    Hi!
    I have a problem with batch, it's not working as expected. At the end, the result of a series of updates, inserts and selects, I have something that is not what I expected. I think the problem is the batch. and I want to remove the batch size, set it to 0. But its not working, I still have problems... I've flushed the session (hibernateSession) but did not solve..


    Thanks in advance.

  • #2
    I don't think there's enough info (for me anyway) to assist. Can you elaborate (stacktrace, code + actual result)?

    Comment


    • #3
      w/o any other information (like what are you trying to do and what do you expect) there isn't much to talk about. AFAIK the batch size acts only as an optimization for lazy loading and should not affect the outcome of the code, only performance.

      Comment


      • #4
        My configuration file and more about the problem

        Hi!! here is more information about my configuration file (applicationContext.xml):

        Code:
        	<bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
        
        		<property name="hibernateProperties">
        			<props>
        				<prop key="show_sql">true</prop>
        				<prop key="hibernate.show_sql">true</prop>
        				<prop key="hibernate.dialect">net.sf.hibernate.dialect.Oracle9Dialect</prop>
        				<prop key="hibernate.jdbc.batch_size">0</prop>
        				<prop key="hibernate.c3p0.max_size">1</prop>
        				<prop key="hibernate.c3p0.min_size">0</prop>
        				<prop key="hibernate.c3p0.timeout">5000</prop>
        				<prop key="hibernate.c3p0.max_statements">100</prop>
        				<prop key="hibernate.c3p0.idle_test_period">300</prop>
        				<prop key="hibernate.c3p0.acquire_increment">2</prop>
        			</props>
        		</property>
        Questions:
        why my application seems to be using batch size other than 0?
        (I say this because when i have an sql exception, it's not thrown exactly on the method that caused it... it's thrown a bit later)
        how can I configure it to not use no batch updates?

        Thanks in advance!![/i]

        Comment


        • #5
          other problem: sql is not appearing

          Guys, there is also another problem, it show_sql=true did not work... it's not showing the sql genereted!!

          Could someone also help me with this!?

          Thanks!!

          Comment


          • #6
            I think you have some configuration error and the sessionFactory defined here is not used - maybe overwritten.

            Comment


            • #7
              here is more of applicationcontext.xml

              more of my applicationContext.xml...
              Could you give me an example of a good configuration for hibernate and spring???

              Code:
              <?xml version="1.0" encoding="UTF-8"?>
              <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http&#58;//www.springframework.org/dtd/spring-beans.dtd">
              <beans>
              	<!-- Data Source -->
              	<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
              		<property name="driverClassName">
              			<value>oracle.jdbc.driver.OracleDriver</value>
              		</property>
              		<property name="url">
              			<value>jdbc&#58;oracle&#58;thin&#58;@10.72.31.38&#58;1521&#58;cdplnd1</value>
              		</property>
              		<property name="username">
              			<value>caduni</value>
              		</property>
              		<property name="password">
              			<value>caduni</value>
              		</property>
              	</bean>
              
              	<!-- Hibernate Mapping -->
              	<bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
              
              		<property name="hibernateProperties">
              			<props>
              				<prop key="show_sql">true</prop>
              				<prop key="hibernate.show_sql">true</prop>
              				<prop key="hibernate.dialect">net.sf.hibernate.dialect.Oracle9Dialect</prop>
              				<prop key="hibernate.jdbc.batch_size">0</prop>
              				<prop key="hibernate.c3p0.max_size">1</prop>
              				<prop key="hibernate.c3p0.min_size">0</prop>
              				<prop key="hibernate.c3p0.timeout">5000</prop>
              				<prop key="hibernate.c3p0.max_statements">100</prop>
              				<prop key="hibernate.c3p0.idle_test_period">300</prop>
              				<prop key="hibernate.c3p0.acquire_increment">2</prop>
              			</props>
              		</property>
              
              		<property name="entityInterceptor">
              			<ref bean="springInterceptor" />
              		</property>
              
              		<property name="mappingResources">
              			<list>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/AvaliacaoCoordenador.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/Visita.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/FichaVisita.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/LoteFichaVisita.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/Visitador.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/HistContaResponsavel.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/Agencia.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/Aluno.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/AlunoRendaMinha.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/AtributoMutante.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/AgricultorAtivAgricol.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/AgricultorEntidadeAssociativa.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/AtividadeAgricola.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/ArgumentoOperacao.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/Bairro.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/Banco.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/BemPosse.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/BeneficiarioPrograma.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/Beneficio.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/BenefProgramaMotivo.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/CadunicoXProfamilia.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/CadunicoXRendaminha.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/Chamada.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/ChamadaBeneficiario.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/ChamadaProgramaBeneficio.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/ChamadaUsuario.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/ChamadaRegiao.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/Despesa.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/DependenteProFamilia.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/DetalheBeneficio.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/DespesaFamilia.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/Empregador.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/EntidadeAssociativa.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/Escola.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/Familia.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/FamiliaAgricultor.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/FamiliaBemPosse.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/FamiliaBemPosseDet.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/FamiliaFolhaPag.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/FolhaPagamento.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/Funcionalidade.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/HistAtribMutante.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/HistPessoaMigrada.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/HistFamiliaPessoa.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/HistFamPesMotivo.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/HistOperacaoUsuario.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/HistoricoOperacaoUsuarioAtributo.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/HistOperacArgumento.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/Localidade.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/Logradouro.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/Motivo.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/Municipio.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/MembroRendaMinha.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/Ocupacao.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/OcupacaoCef.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/Operacao.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/OperacaoStatusAnt.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/Orgao.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/OrgaoOperacao.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/Pagamento.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/Pais.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/Pessoa.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/PessoaTitular.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/PessoaBenefProg.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/PessoaBenProgDet.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/PessoaResponsavelBeneficio.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/PessoaExcluida.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/PessoaFolhaPag.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/PontoDistribuicao.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/PostoSaude.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/ProblemaSaude.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/ProblemaSaudePessoa.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/Programa.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/ProFamilia.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/ProgramaBeneficio.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/ProgramaMigracao.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/Renda.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/RendaPessoa.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/ResponsavelRendaMinha.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/SerieEscolar.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/SigeAluno.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/SigeEscola.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/StatusProgramaBenefic.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/StatusRendaMinha.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/Tipo.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/TipoEsp.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/Uf.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/Usuario.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/UsuarioOrgaoOperacao.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/SigeSerie.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/RendaAgricultor.hbm.xml</value>
              				<value>br/sapiensit/cadastrounico/pojo/hibernate/PessoaRespDetalhe.hbm.xml</value>
              			</list>
              		</property>
              
              		<property name="hibernateProperties">
              			<props>
              				<prop key="hibernate.dialect">net.sf.hibernate.dialect.Oracle9Dialect</prop>
              			</props>
              		</property>
              		<property name="dataSource">
              			<ref bean="dataSource" />
              		</property>
              
              	</bean>

              Comment


              • #8
                if look at your sessionFactory definition you are defining twice the hibernateProperties - the last definition is always used:

                <property name="hibernateProperties">
                <props>
                <prop key="show_sql">true</prop>
                <prop key="hibernate.show_sql">true</prop>
                <prop key="hibernate.dialect">net.sf.hibernate.dialect.O racle9Dialect</prop>
                <prop key="hibernate.jdbc.batch_size">0</prop>
                <prop key="hibernate.c3p0.max_size">1</prop>
                <prop key="hibernate.c3p0.min_size">0</prop>
                <prop key="hibernate.c3p0.timeout">5000</prop>
                <prop key="hibernate.c3p0.max_statements">100</prop>
                <prop key="hibernate.c3p0.idle_test_period">300</prop>
                <prop key="hibernate.c3p0.acquire_increment">2</prop>
                </props>
                </property>
                <property name="hibernateProperties">
                <props>
                <prop key="hibernate.dialect">net.sf.hibernate.dialect.O racle9Dialect</prop>
                </props>
                </property>
                <property name="dataSource">
                <ref bean="dataSource" />
                </property>
                You can find some good, clean examples inside Spring samples.

                Comment


                • #9
                  Yes!! noticed that!!

                  Yes!! I noticed write after posting... maybe some of the programers duplicated it!!!
                  Anyways!!! It did work, and sorry for posting something so stupid on the forum!!

                  Comment


                  • #10
                    - that's why is good to use version control and read the comments. Find the responsible and have a talk with him.

                    Comment

                    Working...
                    X