Hi,
I am currently working on an application that saves PDF files to database.
Environment :
WebSphere 5.11
Oracle 9.2
JRE 1.4
Struts 1.3.8
Spring 2
Hibernate 3
Driver ojdbc14-10.2.0.2
In development mode, with Tomcat 4.1, i didn't have problems saving any file (format, size...).
But with WebSphere, the java object, which contains the Blob, is updated with empty Blob. However, I tested with a small file size (4o) and it works !
Configuration :
applicationContext.xml
Code:
<bean name="propertyPlaceholder" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<value>classpath:jdbc.properties</value>
</property>
</bean>
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="${jdbc.driverClassName}"/>
<property name="url" value="${jdbc.url}"/>
<property name="username" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="mappingLocations">
<list>
<value>classpath*:XX.hbm.xml</value>
...
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.Oracle9Dialect
</prop>
<prop key="connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.bytecode.use_reflection_optimizer">true</prop>
<prop key="hibernate.cache.provider_class">org.hibernate.cache.NoCacheProvider</prop>
<prop key="hibernate.hbm2ddl.auto">none</prop>
<prop key="hibernate.c3p0.min_size">10</prop>
<prop key="hibernate.c3p0.max_size">30</prop>
<prop key="hibernate.c3p0.timeout">100</prop>
<prop key="hibernate.c3p0.max_statements">0</prop>
<prop key="hibernate.jdbc.batch_size">0</prop>
<prop key="hibernate.connection.autocommit">false</prop>
</props>
</property>
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean>
<bean id="jdbcExceptionTranslator"
class="org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator">
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean>
<bean id="hibernateTemplate"
class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
<property name="jdbcExceptionTranslator">
<ref bean="jdbcExceptionTranslator" />
</property>
</bean>
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory" />
</property>
</bean>
Business Object :
Code:
public class NavetteOuvertureBO extends AbstractBO {
private static final long serialVersionUID = -5268286348123584857L;
...
private Blob blobFicheSignee;
/**
* Retourne la propriété blobFicheSignee
* @return blobFicheSignee
*/
public Blob getBlobFicheSignee() {
return blobFicheSignee;
}
/**
* Modifie la propriété blobFicheSignee
* @param blobFicheSignee nouvelle valeur de blobFicheSignee
*/
public void setBlobFicheSignee(Blob blobFicheSignee) {
this.blobFicheSignee = blobFicheSignee;
}
Mapping hibernate file :
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="xx.xx.xx.NavetteOuvertureBO" table="FICHE_OUVERTURE">
<id name="id" column="ID_FICHE_OUVERTURE">
<generator class="sequence">
<param name="sequence">SEQ_FICHE_OUVERTURE</param>
</generator>
</id>
...
<property name="blobFicheSignee" type="blob"
column="BLOB_FICHE_SIGNEE" lazy="true"/>
</class>
</hibernate-mapping>
Business Service :
Code:
public void signerNavetteBO(Long id, byte[] fichier, String fileName) throws ApplicationException {
Blob blobFicheSignee = Hibernate.createBlob(fichier);
ficheNavetteBO.setBlobFicheSignee(blobFicheSignee);
ficheNavetteBO.setNomFicheSignee(fileName);
this.getNavetteFermetureDAO().updateNavetteFermetureBO(ficheNavetteBO);
And the DAO :
Code:
public void updateNavetteOuvertureBO(NavetteOuvertureBO navette) throws TechnicalException {
NavetteOuvertureBO ancienneNavette = this.getNavetteOuvertureBO(navette.getId());
if (ancienneNavette == null) {
throw new TechnicalException(ExceptionMessages.ERREUR_TECHNIQUE_CONCURRENT_SUPPRESSION);
}
this.getHibernateTemplate().evict(ancienneNavette);
this.getHibernateTemplate().update(navette);
}
I searched on many forums: changing properties hibernate, use the OCI driver without success.
Thank you for your help