Results 1 to 10 of 10

Thread: Problem with hibernate batch (a bit urgent)

  1. #1
    Join Date
    Jun 2005
    Posts
    8

    Default 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. #2
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,104

    Default

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

  3. #3
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    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.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  4. #4
    Join Date
    Jun 2005
    Posts
    8

    Default 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]

  5. #5
    Join Date
    Jun 2005
    Posts
    8

    Default 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!!

  6. #6
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    I think you have some configuration error and the sessionFactory defined here is not used - maybe overwritten.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  7. #7
    Join Date
    Jun 2005
    Posts
    8

    Default 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>

  8. #8
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    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.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  9. #9
    Join Date
    Jun 2005
    Posts
    8

    Default 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!!

  10. #10
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    - that's why is good to use version control and read the comments. Find the responsible and have a talk with him.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

Similar Threads

  1. Replies: 5
    Last Post: Dec 27th, 2005, 07:00 AM
  2. Replies: 1
    Last Post: Jul 5th, 2005, 03:48 AM
  3. Replies: 3
    Last Post: Nov 19th, 2004, 07:16 PM
  4. Replies: 5
    Last Post: Aug 27th, 2004, 07:13 PM
  5. Replies: 7
    Last Post: Aug 21st, 2004, 03:42 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •