private String parsePropertyName ( String orgPropertyName , Object userData ) { // try to assure the correct separator is used String propertyName = orgPropertyName . replace ( HibernateLayerUtil . XPATH_SEPARATOR , HibernateLayerUtil . SEPARATOR ) ; // split the path (separator is defined in the HibernateLayerUtil) String [ ] props = propertyName . split ( HibernateLayerUtil . SEPARATOR_REGEXP ) ; String finalName ; if ( props . length > 1 && userData instanceof Criteria ) { // the criteria API requires an alias for each join table !!! String prevAlias = null ; for ( int i = 0 ; i < props . length - 1 ; i ++ ) { String alias = props [ i ] + "_alias" ; if ( ! aliases . contains ( alias ) ) { Criteria criteria = ( Criteria ) userData ; if ( i == 0 ) { criteria . createAlias ( props [ 0 ] , alias ) ; } else { criteria . createAlias ( prevAlias + "." + props [ i ] , alias ) ; } aliases . add ( alias ) ; } prevAlias = alias ; } finalName = prevAlias + "." + props [ props . length - 1 ] ; } else { finalName = propertyName ; } return finalName ; }
Go through the property name to see if it is a complex one . If it is aliases must be declared .