编程总结(六)

 

 27. Spring3.0的

 

<bean class="org.springframework.beans.factory.config.CustomEditorConfigurer">
    <property name="customEditors">
       <map>
            <entry key="java.util.Date"  value="com.hilatest.common.spring.CalendarPropertyEditor">
            </entry>
       </map>
    </property>
   </bean>

 

 
  这是配置一段属性编辑器。在3.0之前。后面value可以用ref。但是3.0之后,就不能这样来用了。因为在3.0版本中。负责接收在 CustomEditorConfigurer类中负责存放配置信息的是 customEditors的类型是Map<String, String>。而之前配置的Map。CustomEditorConfigurer类中,负责装配的是 postProcessBeanFactory方法

28.Spring3.0和Hibernate3.0好像有冲突。包是asm.jar

29.Hibernate3
       要使用getCurrentSession。需要在配置文件中加入<property name="hibernate.current_session_context_class">thread</property& gt;。当然是在没有使用Spring的情况下
       getCurrentSession之后。是以事务即是Session。
      

Session session = SessionFactory.getCurrentSession();
       Transaction  tx = session.beginTransaction();
       tx.commit;
       session.close;               //这里会报Session以关闭的错

 

30.Spring Aop代理
       对于新手来说,估计很容易疏忽的地方。

     

 <aop:config proxy-target-class="true">
              </aop:config> 

 
       If the target object to be proxied implements at least one interface then a JDK dynamic proxy will be used. All of the interfaces implemented by the target type will be proxied. If the target object does not implement any interfaces then a CGLIB proxy will be created.
          这是reference上面的原话。在7.6。因该能说明问题了。而proxy-target-class="true"则是强制spring用 CGlib代理

31 今天碰到一个问题。是管理Spring的事务和Hibernate的lazy冲突的一个问题。这里说冲突,有点过分。
    

 public class Foo{
            List list;
            public String toStirng(){
               return list.toString(); 
           }
     }

 
     这样的一个类吧。用Hibernate和list进行了集成。然后list用了lazy。spring配置了事务管理。然后调用toString方法时就会报错。原因是。由于从Hibernate中从数据库中抽取,然后组装的pojo类(这里的Foo的实例)。并不受Spring来管理。所以Spring 管理的事务。没有办法影响到他。所以在运行的时候,其就会报Session以关闭。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值