From: <one...@us...> - 2003-01-12 07:07:52
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/hql In directory sc8-pr-cvs1:/tmp/cvs-serv5675/src/net/sf/hibernate/hql Modified Files: PreprocessingParser.java Log Message: added isFirst(), isLast() to ScrollableResults fixed problem finding properties inherited by interfaces and abstract classes support for elements(), indices(), max(), min(), count() functions Index: PreprocessingParser.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/hql/PreprocessingParser.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PreprocessingParser.java 5 Jan 2003 02:11:21 -0000 1.3 --- PreprocessingParser.java 12 Jan 2003 07:07:48 -0000 1.4 *************** *** 2,5 **** --- 2,6 ---- package net.sf.hibernate.hql; + import java.util.HashMap; import java.util.HashSet; import java.util.Map; *************** *** 14,17 **** --- 15,19 ---- private static final Set operators; + private static final Map collectionProps; static { operators = new HashSet(); *************** *** 31,34 **** --- 33,45 ---- operators.add("not between"); operators.add("not exists"); + + collectionProps = new HashMap(); + collectionProps.put("elements", "elements"); + collectionProps.put("indices", "indices"); + collectionProps.put("count", "size"); + collectionProps.put("maxindex", "maxIndex"); + collectionProps.put("minindex", "minIndex"); + collectionProps.put("max", "maxElement"); + collectionProps.put("min", "minElement"); } *************** *** 38,41 **** --- 49,53 ---- private ClauseParser parser = new ClauseParser(); private String lastToken; + private String currentCollectionProp; public PreprocessingParser(Map replacements) { *************** *** 69,72 **** --- 81,104 ---- String substoken = (String) replacements.get(token); token = (substoken==null) ? token : substoken; + + //handle HQL2 collection syntax + if ( currentCollectionProp!=null ) { + if ( "(".equals(token) ) { + return; + } + else if ( ")".equals(token) ) { + currentCollectionProp=null; + return; + } + else { + token+='.'+currentCollectionProp; + } + } + + String prop = (String) collectionProps.get( token.toLowerCase() ); + if ( prop!=null ) { + currentCollectionProp = prop; + } + //handle <=, >=, !=, is not, not between, not in |