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以关闭。