1.hibernate search 已经有4.0.0.Final 版本了
正好手头再做新的项目,升级下
一升级,发现代码很多错误,发现有两个类发生了重要的变化
第一个是 枚举org.hibernate.search.annotations.Index
4.0.0以前的版本 里面的枚举是这样的
/**
* Do not index the field value. This field can thus not be searched,
* but one can still access its contents provided it is
* {@link Store stored}.
*/
NO,
/**
* Index the field's value so it can be searched. An Analyzer will be used
* to tokenize and possibly further normalize the text before its
* terms will be stored in the index. This is useful for common text.
*/
TOKENIZED,
/**
* Index the field's value without using an Analyzer, so it can be searched.
* As no analyzer is used the value will be stored as a single term. This is
* useful for unique Ids like product numbers.
*/
UN_TOKENIZED,
/**
* Index the field's value without an Analyzer, and disable
* the storing of norms. No norms means that index-time boosting
* and field length normalization will be disabled. The benefit is
* less memory usage as norms take up one byte per indexed field
* for every document in the index.
*/
NO_NORMS
4.0.0里面的这个枚举是这样的
/**
* Index the field value.
*/
YES,
/**
* Do not index the field value. This field can thus not be searched,
* but one can still access its contents provided it is
* {@link Store stored}.
*/
NO
简洁了许多
所以 以前的 org.hibernate.search.annotations.Index.TOKENIZED 代码 要改成 org.hibernate.search.annotations.Index.YES
2.顺带还发现 @org.hibernate.annotations.Entity 这个annotation 已经@Deprecated了 ,而且javadoc 里面写得很清楚 To be removed in 4.1,呵呵人家已经和你打招呼了
所以 我们原来的乐观锁@org.hibernate.annotations.Entity(optimisticLock = OptimisticLockType.VERSION) 要改成 @OptimisticLocking(type = OptimisticLockType.VERSION),这个annotation 默认采用的是 OptimisticLockType type() default OptimisticLockType.VERSION;
所以,如果你的乐观锁是采用version column 那么 可以简写成 @OptimisticLocking
要改成
第二,原来的
org.hibernate.search.filter.CachingWrapperFilter 已经该成 org.hibernate.search.filter.impl.CachingWrapperFilter;
3.spring 从3.0.6 升级到3.1.0
发现
private UrlMatcher urlMatcher = new AntUrlPathMatcher();;
UrlMatcher 和 AntUrlPathMatcher 这两个类不见了
org.springframework.security.web.util.AntUrlPathMatcher;
import org.springframework.security.web.util.UrlMatcher;
取而代之的是
import org.springframework.util.AntPathMatcher;
import org.springframework.util.PathMatcher;
而且写法也不一样了
要这么写
FilterInvocation filterInvocation = (FilterInvocation) object;
HttpServletRequest request = filterInvocation.getHttpRequest();
RequestMatcher requestMatcher = new AntPathRequestMatcher(resURL);
requestMatcher.matches(request)
在这里,如果你们的项目有成熟 的架构,我不建议各位去升级
要改动的地方很多