Menu

No From with CCriteriaCondition

2004-09-30
2013-03-07
  • Nobody/Anonymous

    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.

     
    • Nobody/Anonymous

      You have to set the tables collection yourself on the CCriteriaCondition

       
    • Richard Banks

      Richard Banks - 2004-10-01

      Yes, the second post is right.

      You do it using
      criCond.ClassMap = myObject.getClassMap

      (or something similar).

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.