Bonjour,
j'utilise hibernate 3.2.0cr2 via le container ejb3 standalone de jboss. La base de données est Postgresql 8.1 .
Lorsque j'essaie de configurer la propriété hibernate.jdbc.batch_size en l'initialisant à 20 par exemple, celle ci ne semble pas être prise en compte. J'ai une entité account avec une relation one to tone avec une entite contact et lors de la mise a jour et de l insertion, le batch_size est à 1:
J 'ai realise la maj avec un merge.
Code:
17:33:09,300 DEBUG [AbstractBatcher] about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
17:33:09,300 DEBUG [ConnectionManager] opening JDBC connection
17:33:09,300 DEBUG [SQL]
/* insert fr.ccip.gefi.domain.Contact
*/ insert
into
Contact
(name, firstname, address, zip, city, country, phoneNumber, faxNumber, email, DTYPE, id)
values
(?, ?, ?, ?, ?, ?, ?, ?, ?, 'Contact', ?)
Hibernate:
/* insert fr.ccip.gefi.domain.Contact
*/ insert
into
Contact
(name, firstname, address, zip, city, country, phoneNumber, faxNumber, email, DTYPE, id)
values
(?, ?, ?, ?, ?, ?, ?, ?, ?, 'Contact', ?)
17:33:09,300 DEBUG [AbstractBatcher] Executing batch size: 1
17:33:09,310 DEBUG [AbstractBatcher] about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
17:33:09,310 DEBUG [ConnectionManager] skipping aggressive-release due to flush cycle
17:33:09,310 DEBUG [UpdateTimestampsCache] Pre-invalidating space [Account]
17:33:09,310 DEBUG [AbstractBatcher] about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
17:33:09,310 DEBUG [SQL]
/* update
fr.ccip.gefi.domain.Account */ update
Account
set
name=?,
primary_contact_fk=?,
company_contact_fk=?
where
id=?
Hibernate:
/* update
fr.ccip.gefi.domain.Account */ update
Account
set
name=?,
primary_contact_fk=?,
company_contact_fk=?
where
id=?
17:33:09,310 DEBUG [AbstractBatcher] Executing batch size: 1
17:33:09,350 DEBUG [AbstractBatcher] about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
17:33:09,350 DEBUG [ConnectionManager] skipping aggressive-release due to flush cycle
17:33:09,350 DEBUG [ConnectionManager] aggressively releasing JDBC connection
17:33:09,350 DEBUG [ConnectionManager] releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
17:33:09,360 DEBUG [UpdateTimestampsCache] Invalidating space [Contact], timestamp: 4810376762818560
17:33:09,360 DEBUG [UpdateTimestampsCache] Invalidating space [Account], timestamp: 4810376762818561
17:33:09,360 DEBUG [JDBCContext] TransactionFactory reported no active transaction; Synchronization not registered
17:33:09,360 DEBUG [ManagedEntityManagerFactory] ************** closing entity managersession **************
Je ne comprends pas pourquoi il semble avoir 2 prepared statement d'ouverts et qu hibernate ne realise pas un batch jdbc (1 seul prepared statement et une execution de la totalite dans un meme prepared statement.
Pour l insertion, je devine que, vu que mes pk sont generees par la sequence hibernate, hibernate a besoin de recuperer la pk generee pour l inserer dans l autre entite, mais pour l update, je ne vois ou ca cloche.
Pourriez vous me dire si je me trompe et/ou comment realiser reellement un batch en update / insert.
Merci d avance de votre aide
alexandre