在hibernate搜索中,您可以为此创建一个自定义Bridge。
类似于以下内容:
@FieldBridge(impl = com.myco.myapp.CollectionCountBridge.class)@ContainedIn@oneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="TParent")public Set<TChild> getTChildSet() { return this.TChildSet;}使用自定义桥实现:
public class CollectionCountBridge extends PaddedIntegerBridge { @Override public String objectToString(Object object) { if (object == null || (!(object instanceof Collection))) { return null; } Collection<?> coll = (Collection<?>) object; return super.objectToString(coll.size()); }}


