`

Hibernate源码研究碎得(2)

阅读更多


1, 为什么tables用的是TreeMap这个类呢?而别的大都用的是HashMap
2, Environment.getProperties()每次调用都是新建一个Properties对象,把这个对象传对调用者.这样做用什么特殊的好处呢?
3, 怪,怎么会出现一模一样的两行LogInfo呢?
 [2008-05-05 09:16:36,750] INFO  org.hibernate.cfg.Environment Hibernate 3.2.6
 [2008-05-05 09:16:36,750] INFO  org.hibernate.cfg.Environment Hibernate 3.2.6
 
 这是log4j配置时哪出错了?
4,跟Tomcat对配置文件的解析相比,Hibernate对配置文件的解析用的是那种DOM,也就是说把XML文件生成一个Document放在内存中,什么时候用就直接用.而Tomcat像是用SAX解析方式,根据解析事件去配置相应的Component.

5,url.openStream()?为什么要用这个而不用那种直接的打开方式呢?

6,注意有两个类Mappings与Mapping,
 Mappings是在解析hbm.xml时

7,hibernate-mapping里的子元素Meta还没有用过.这个怎么与别的联系起来?

8,有专门的extractRootAttributes方法来get RootNote下的attributes,这也进一步证明了上面的Meta是RootNode的子元素而不是其属性.

9,看hibernate-mapping-3.0.dtd又进一步想到了正则表达式中也会用到的*?等对个数限制的描述符.
 *: 表示任意个数,0 --> N.
 ?: 表示0 or 1吗现在也不确定了.
10,dtd描述文件中的像如下所示中的
 <!ATTLIST hibernate-mapping default-cascade CDATA "none">

 CDATA是什么意思?

11,Map put时的一个新发现:
 Object old = classes.put( persistentClass.getEntityName(), persistentClass );
  if ( old!=null ) {
   throw new DuplicateMappingException( "class/entity", persistentClass.getEntityName() );
 }

 Hibernate中有如上的应用,也就是说可以能过put的返回值是否为null来判断是否覆盖了Map中与Key相对的原用Entity.不错.

 再看API,对put的返回值有如下描述:
 the previous value associated with  key , or null  if there was no mapping for  key .(A  null  return can also indicate that the map previously associated  null  with  key , if the implementation supports  null  values.)

12,HmbBinder类中的bindPojoRepresentation这三个方法bind的是从DB返回后的包装类型么?

6
8
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics