model.xml配置
resultMap属性:
<result property="img" column="img" jdbcType="blob" javaType="byte" typeHandler="org.springframework.orm.ibatis.support.BlobByteArrayTypeHandler"/>
INSERT INTO share_sina_weibo (img)VALUES(,#img,handler=org.springframework.orm.ibatis.support.BlobByteArrayTypeHandler#)
需要配置事物
spring . XML
<!-- 声明式事务管理 -->
<bean id="baseTransactionProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"
abstract="true">
<property name="transactionManager" ref="activityTransactionManager"></property>
<property name="transactionAttributes">
<props>
<prop key="update">PROPAGATION_REQUIRED</prop>
<prop key="insert">PROPAGATION_REQUIRED</prop>
<prop key="delete">PROPAGATION_REQUIRED</prop>
<prop key="*">readOnly</prop>
</props>
</property>
</bean>
<bean id="shareSinaWeiboDAO" parent="baseTransactionProxy">
<property name="target">
<bean class="com.xxx.ShareSinaWeiboDAOImpl">
<property ref="xxxFactory" name="sqlMapClient"/>
</bean>
</property>
</bean>