让人抓狂的(Open)JPA

OpenJPA的确让我这几天很抓狂,它不够健壮是一方面的问题,光看看Apache上大量的bug就足以说明,它还是个孩子,需要很多人来改正他。或许不该太埋怨OpenJPA,JPA那些层出不穷的annotation,就让人望而生畏,再加上不够健壮的实现,让我觉着不知道是谁搞出了我无法解出的问题。

ORM本来号称是改善了开发者在存储数据时面临的面向对象和关系数据库映射问题,但徒增的过量annotation和不稳定的OpenJPA实现,对于不甚了解的开发者来说,真的是好事么?

Jar Hell

JAR hell is a term similar to DLL hell used to describe all the various ways in which the classloading process can end up not working.[8] Three ways JAR hell can occur are explained below:

  • The first case is when a developer or deployer of a Java application has accidentally made two different versions of a library available to the system. This will not be considered an error by the system. Rather, the system will load classes from one or the other library. Adding the new library to the list of available libraries instead of replacing it, may see the application still behaving as though the old library is in use, which it may well be.
  • Another version of the problem arises when two libraries (or a library and the application) require different versions of the same third library. If both versions of the third library use the same class names, there is no way to load both versions of the third library with the same classloader.
  • The most complex JAR hell problems arise in circumstances that take advantage of the full complexity of the classloading system. A Java program is not required to use only a single “flat” classloader, but instead may be composed of several (or, in fact, an indefinite number of) nested, cooperating classloaders. Classes loaded by different classloaders may interact in complex ways not fully comprehended by a developer, leading to inexplicable errors or bugs.

via Java Classloader – Wikipedia, the free encyclopedia.

Dynamic SCRIPT and STYLE elements in IE

var ss1 = document.createElement('style');
var def = 'body {color: red;}';
ss1.setAttribute("type", "text/css");
if (ss1.styleSheet) {   // IE
    ss1.styleSheet.cssText = def;
} else {                // the world
    var tt1 = document.createTextNode(def);
    ss1.appendChild(tt1);
}
var hh1 = document.getElementsByTagName('head')[0];
hh1.appendChild(ss1);

via Dynamic SCRIPT and STYLE elements in IE / Stoyan’s phpied.com.