Posts tagged java

Why interface

“the key benefit of DI is loose coupling. If an object only knows about its dependencies by their interface then the dependency can be swapped out with a different implementation without the depending object knowing the difference” Spring in action

JPA create sql error

在创建entity的时候要注意entity的名字是否是对应的db的保留字 现在的开发中用到了lock这个entity,在persistence的时候出现错误: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘Lock (lockOwner_UU ID, version_UUID, UUID) values (‘ff808181211ae76901211ae76c2c0′ at line 1 因为lock是mysql的保留字。 mysql的所有保留字可以在下面的网页里查到 http://dev.mysql.com/doc/refman/5.1/en/reserved-words.html

InputStream

还真是stream,读掉,就没了。真正的流走了。 读一个文件到inputstream, 用jaxb转换为element后,stream里就没有东西了,再想把他转换为string,得到的就是空的。

java.lang.IncompatibleClassChangeError: Implementing class

Every time I have seen this kind of error it was because I changed a class that other classes depended on, but did not recompile the dependent classes. 开发web程序的时候要deploy,可能会导致server段的class是旧的