Been trying out the framework. Impressive.
However, when using a CCriteriaCondtion all sql statements are missing the From table. When no criteria specified, sql statements are all fine.
Problem seems to be in CPersistentCriteria.ClassMap
the following code only adds a table (which is the table in the FROM clause) if there is no WHERE clause. If there is a where clause (i.e. Specific criteria has been specified via a CCriteriaCondition object) no table is added to the collection and thus bad sql is formed.
If WhereCondition Is Nothing Then
cm = m_classMap
Do
Tables.Add(cm.Tables.Item(1))
cm = cm.SuperClass
Loop While Not cm Is Nothing
criCond = New CCriteriaCondition
criCond.ClassMap = Me.ClassMap
criCond.Tables = Me.Tables
criCond.Associations = Me.Associations
WhereCondition = criCond
End If
If there is a WHERE clause, when/where is a table added to the PersitentCriteria object? Or do I have to do it myself?
Simple code sample using CCriteriaCondition would suffice.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Been trying out the framework. Impressive.
However, when using a CCriteriaCondtion all sql statements are missing the From table. When no criteria specified, sql statements are all fine.
Problem seems to be in CPersistentCriteria.ClassMap
the following code only adds a table (which is the table in the FROM clause) if there is no WHERE clause. If there is a where clause (i.e. Specific criteria has been specified via a CCriteriaCondition object) no table is added to the collection and thus bad sql is formed.
If WhereCondition Is Nothing Then
cm = m_classMap
Do
Tables.Add(cm.Tables.Item(1))
cm = cm.SuperClass
Loop While Not cm Is Nothing
criCond = New CCriteriaCondition
criCond.ClassMap = Me.ClassMap
criCond.Tables = Me.Tables
criCond.Associations = Me.Associations
WhereCondition = criCond
End If
If there is a WHERE clause, when/where is a table added to the PersitentCriteria object? Or do I have to do it myself?
Simple code sample using CCriteriaCondition would suffice.
You have to set the tables collection yourself on the CCriteriaCondition
Yes, the second post is right.
You do it using
criCond.ClassMap = myObject.getClassMap
(or something similar).