After investigation in the code
This behaviour COULD NOT WORK with Hibernate since some code has not yet been done
Ths missing code should re-order the alias with the order of the maps
in : net.sf.hibernate.loader.CriteriaLoader.java.
I made a path which does the trick for my usecases but it's not generic ...
protected String generateTableAlias(String className, int n, String path, boolean isLinkTable) {
if (!isLinkTable) {
String userDefinedAlias = criteria.getAlias(path);
if (userDefinedAlias!=null) {
// modif Gauthier Peel
int position;
if(aliases.size()==0)
{
position = 0;
}else
{
position = aliases.size() -1;
}
aliases.add(position, userDefinedAlias); //very dodgy: depends upon the superclass not reordering things!
return userDefinedAlias;
}
}
String generatedAlias = super.generateTableAlias(className, n, path, isLinkTable);
aliases.add(generatedAlias);
return generatedAlias;
}
instead of the original :
protected String generateTableAlias(String className, int n, String path, boolean isLinkTable) {
if (!isLinkTable) {
String userDefinedAlias = criteria.getAlias(path);
if (userDefinedAlias!=null) {
aliases.add(userDefinedAlias); //very dodgy: depends upon the superclass not reordering things!
return userDefinedAlias;
}
}
String generatedAlias = super.generateTableAlias(className, n, path, isLinkTable);
aliases.add(generatedAlias);
If someone could tell me if this feature is in progress ?
_________________ Gauthier P.
|