to.etc.domui.hibernate.model
Class CriteriaCreatingVisitor

java.lang.Object
  extended by to.etc.webapp.query.QNodeVisitorBase
      extended by to.etc.domui.hibernate.model.CriteriaCreatingVisitor
All Implemented Interfaces:
QNodeVisitor

public class CriteriaCreatingVisitor
extends QNodeVisitorBase

Thingy which creates a Hibernate Criteria thingy from a generic query. This is harder than it looks because the Criteria and DetachedCriteria kludge and Hibernate's metadata dungheap makes generic work very complex and error-prone.

It might be a better idea to start generating SQL from here, using Hibernate internal code to instantiate the query's result only.

Please look a Bug 640 for more details, and see the wiki page http://info.etc.to/xwiki/bin/view/Main/UIAbstractDatabase for more details on the working of all this.

Author:
Frits Jalvingh Created on Jun 24, 2008

Constructor Summary
CriteriaCreatingVisitor(Session ses, Criteria crit)
           
 
Method Summary
 void checkHibernateClass(java.lang.Class<?> clz)
          Does a check to see if the class is a persistent class- because Hibernate itself is too bloody stupid to do it.
 void visitBetween(QBetweenNode n)
           
 void visitCriteria(QCriteria<?> qc)
           
 void visitExistsSubquery(QExistsSubquery<?> q)
          Child-related subquery: determine existence of children having certain characteristics.
 void visitLiteral(QLiteral n)
           
 void visitMulti(QMultiNode inn)
          Compound.
 void visitMultiSelection(QMultiSelection n)
           
 void visitOrder(QOrder o)
           
 void visitPropertyComparison(QPropertyComparison n)
           
 void visitPropertySelection(QPropertySelection n)
           
 void visitRestrictionsBase(QCriteriaQueryBase<?> n)
           
 void visitSelection(QSelection<?> s)
           
 void visitSelectionColumn(QSelectionColumn n)
           
 void visitSelectionItem(QSelectionItem n)
           
 void visitSelectionSubquery(QSelectionSubquery n)
           
 void visitUnaryNode(QUnaryNode n)
           
 void visitUnaryProperty(QUnaryProperty n)
           
 
Methods inherited from class to.etc.webapp.query.QNodeVisitorBase
visitOrderList, visitSelectionColumns
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CriteriaCreatingVisitor

public CriteriaCreatingVisitor(Session ses,
                               Criteria crit)
Method Detail

checkHibernateClass

public void checkHibernateClass(java.lang.Class<?> clz)
Does a check to see if the class is a persistent class- because Hibernate itself is too bloody stupid to do it. Querying an unknown class in Hibernate will return an empty result set, sigh.

Parameters:
clz -

visitRestrictionsBase

public void visitRestrictionsBase(QCriteriaQueryBase<?> n)
                           throws java.lang.Exception
Specified by:
visitRestrictionsBase in interface QNodeVisitor
Overrides:
visitRestrictionsBase in class QNodeVisitorBase
Throws:
java.lang.Exception

visitCriteria

public void visitCriteria(QCriteria<?> qc)
                   throws java.lang.Exception
Specified by:
visitCriteria in interface QNodeVisitor
Overrides:
visitCriteria in class QNodeVisitorBase
Throws:
java.lang.Exception

visitPropertyComparison

public void visitPropertyComparison(QPropertyComparison n)
                             throws java.lang.Exception
Specified by:
visitPropertyComparison in interface QNodeVisitor
Overrides:
visitPropertyComparison in class QNodeVisitorBase
Throws:
java.lang.Exception

visitBetween

public void visitBetween(QBetweenNode n)
                  throws java.lang.Exception
Specified by:
visitBetween in interface QNodeVisitor
Overrides:
visitBetween in class QNodeVisitorBase
Throws:
java.lang.Exception

visitMulti

public void visitMulti(QMultiNode inn)
                throws java.lang.Exception
Compound. Ands and ors.

Specified by:
visitMulti in interface QNodeVisitor
Overrides:
visitMulti in class QNodeVisitorBase
Throws:
java.lang.Exception
See Also:
QNodeVisitorBase.visitMulti(to.etc.webapp.query.QMultiNode)

visitOrder

public void visitOrder(QOrder o)
                throws java.lang.Exception
Specified by:
visitOrder in interface QNodeVisitor
Overrides:
visitOrder in class QNodeVisitorBase
Throws:
java.lang.Exception

visitUnaryNode

public void visitUnaryNode(QUnaryNode n)
                    throws java.lang.Exception
Specified by:
visitUnaryNode in interface QNodeVisitor
Overrides:
visitUnaryNode in class QNodeVisitorBase
Throws:
java.lang.Exception

visitUnaryProperty

public void visitUnaryProperty(QUnaryProperty n)
                        throws java.lang.Exception
Specified by:
visitUnaryProperty in interface QNodeVisitor
Overrides:
visitUnaryProperty in class QNodeVisitorBase
Throws:
java.lang.Exception

visitLiteral

public void visitLiteral(QLiteral n)
                  throws java.lang.Exception
Specified by:
visitLiteral in interface QNodeVisitor
Overrides:
visitLiteral in class QNodeVisitorBase
Throws:
java.lang.Exception

visitExistsSubquery

public void visitExistsSubquery(QExistsSubquery<?> q)
                         throws java.lang.Exception
Child-related subquery: determine existence of children having certain characteristics. Because the worthless Hibernate "meta model" API and the utterly disgusting way that mapping data is "stored" in Hibernate we resort to getting the generic type of the child property's collection to determine the type where the subquery is executed on.

Specified by:
visitExistsSubquery in interface QNodeVisitor
Overrides:
visitExistsSubquery in class QNodeVisitorBase
Throws:
java.lang.Exception
See Also:
QNodeVisitorBase.visitExistsSubquery(to.etc.webapp.query.QExistsSubquery)

visitMultiSelection

public void visitMultiSelection(QMultiSelection n)
                         throws java.lang.Exception
Specified by:
visitMultiSelection in interface QNodeVisitor
Overrides:
visitMultiSelection in class QNodeVisitorBase
Throws:
java.lang.Exception

visitSelection

public void visitSelection(QSelection<?> s)
                    throws java.lang.Exception
Specified by:
visitSelection in interface QNodeVisitor
Overrides:
visitSelection in class QNodeVisitorBase
Throws:
java.lang.Exception

visitSelectionColumn

public void visitSelectionColumn(QSelectionColumn n)
                          throws java.lang.Exception
Specified by:
visitSelectionColumn in interface QNodeVisitor
Overrides:
visitSelectionColumn in class QNodeVisitorBase
Throws:
java.lang.Exception

visitSelectionItem

public void visitSelectionItem(QSelectionItem n)
                        throws java.lang.Exception
Specified by:
visitSelectionItem in interface QNodeVisitor
Overrides:
visitSelectionItem in class QNodeVisitorBase
Throws:
java.lang.Exception

visitPropertySelection

public void visitPropertySelection(QPropertySelection n)
                            throws java.lang.Exception
Specified by:
visitPropertySelection in interface QNodeVisitor
Overrides:
visitPropertySelection in class QNodeVisitorBase
Throws:
java.lang.Exception

visitSelectionSubquery

public void visitSelectionSubquery(QSelectionSubquery n)
                            throws java.lang.Exception
Specified by:
visitSelectionSubquery in interface QNodeVisitor
Overrides:
visitSelectionSubquery in class QNodeVisitorBase
Throws:
java.lang.Exception