-->
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.  [ 1 post ] 
Author Message
 Post subject: Batch_size problem
PostPosted: Tue Apr 19, 2005 11:51 am 
Newbie

Joined: Wed Apr 13, 2005 8:58 am
Posts: 2
Hello,

I'd like to insert five object Price in my DB; I thougth if I set hibernate.jdbc.batch_size=30, hibernate will perform one request. It does 5 request. Why can I do to solve this pb ?
Leto

Hibernate: select seq_priceid.nextval from dual
Hibernate: insert into PRICE (vatRate, price, start_date, end_date, id) values (?, ?, ?, ?, ?)
Hibernate: select seq_priceid.nextval from dual
Hibernate: insert into PRICE (vatRate, price, start_date, end_date, id) values (?, ?, ?, ?, ?)
Hibernate: select seq_priceid.nextval from dual
Hibernate: insert into PRICE (vatRate, price, start_date, end_date, id) values (?, ?, ?, ?, ?)
Hibernate: select seq_priceid.nextval from dual
Hibernate: insert into PRICE (vatRate, price, start_date, end_date, id) values (?, ?, ?, ?, ?)
Hibernate: select seq_priceid.nextval from dual
Hibernate: insert into PRICE (vatRate, price, start_date, end_date, id) values (?, ?, ?, ?, ?)

Hibernate version:2

<?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="com.presseinfo.netful.model.product.Price"
table="PRICE"
dynamic-update="false"
dynamic-insert="false"
select-before-update="false"
optimistic-lock="version"
batch-size="50"
>

<id
name="id"
column="id"
type="java.lang.Long"
unsaved-value="null"
>
<generator class="sequence">
<param name="sequence">seq_priceid</param>
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-Price.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>

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

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

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

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

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

</class>

</hibernate-mapping>


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<!-- [<!ENTITY % mapping-include-dao SYSTEM "mapping-include-dao.ent">%mapping-include-dao;]-->
<!-- [<!ENTITY % mapping-include-connector SYSTEM "mapping-include-connector.ent">%mapping-include-connector;] -->

<beans>
<!-- Hibernate SessionFactory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
<property name="dataSource"><ref bean="dataSource"/></property>
<property name="mappingResources">
<list>
<value>com/presseinfo/netful/model/product/Price.hbm.xml</value>
</list>
</property>
<!-- The property below is commented out b/c it doesn't work when run via
Ant in Eclipse. It works fine for individual JUnit tests and in IDEA ??
<property name="mappingJarLocations">
<list><value>file:dist/appfuse-dao.jar</value></list>
</property>
-->
<property name="hibernateProperties">
<props>
<prop key="hibernate.cache.provider_class">net.sf.hibernate.cache.EhCacheProvider</prop>
<prop key="hibernate.use_outer_join">true</prop>
<prop key="hibernate.max_fetch_depth">10</prop>
<prop key="hibernate.jdbc.batch_size">30</prop>
<prop key="hibernate.jdbc.use_scrollable_resultsets">true</prop>
<prop key="hibernate.dialect">net.sf.hibernate.dialect.Oracle9Dialect</prop>
<prop key="hibernate.show_sql">true</prop>
<!--prop key="hibernate.hbm2ddl.auto">update</prop-->
</props>
</property>
</bean>

<!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
<bean id="transactionManager" class="org.springframework.orm.hibernate.HibernateTransactionManager">
<property name="sessionFactory"><ref local="sessionFactory"/></property>
</bean>

<!-- Generic DAO - can be used when doing standard CRUD -->
<bean id="dao" class="com.presseinfo.netful.dao.hibernate.BaseDAOHibernate">
<property name="sessionFactory"><ref local="sessionFactory"/></property>
</bean>
</beans>




String[] paths ={"/test/connector/conf/applicationContext-resources.xml",
"/test/connector/conf/applicationContext-connector-hibernate.xml"};
System.out.println("*********************************");
try {
ctx = new FileSystemXmlApplicationContext(paths);
} catch (Exception exx) {
exx.printStackTrace();
}

BaseDAOHibernate baseDAOHibernate = (BaseDAOHibernate) ctx.getBean("dao");
for (int i = 0; i <5; i++) {
Price price = new Price();
price.setId(new Long(i));
price.setVatRate(new Double(i+1));
baseDAOHibernate.getHibernateTemplate().save(price);

}



Hibernate: select seq_priceid.nextval from dual
Hibernate: insert into PRICE (vatRate, price, start_date, end_date, id) values (?, ?, ?, ?, ?)
Hibernate: select seq_priceid.nextval from dual
Hibernate: insert into PRICE (vatRate, price, start_date, end_date, id) values (?, ?, ?, ?, ?)
Hibernate: select seq_priceid.nextval from dual
Hibernate: insert into PRICE (vatRate, price, start_date, end_date, id) values (?, ?, ?, ?, ?)
Hibernate: select seq_priceid.nextval from dual
Hibernate: insert into PRICE (vatRate, price, start_date, end_date, id) values (?, ?, ?, ?, ?)
Hibernate: select seq_priceid.nextval from dual
Hibernate: insert into PRICE (vatRate, price, start_date, end_date, id) values (?, ?, ?, ?, ?)


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

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.