GroupBy query calls default constructor when object should be null
------------------------------------------------------------------

                 Key: IBATISNET-216
                 URL: https://issues.apache.org/jira/browse/IBATISNET-216
             Project: iBatis for .NET
          Issue Type: Bug
          Components: DataMapper
    Affects Versions: DataMapper 1.6.2
         Environment: .NET 2.0, Sql Server 2000
            Reporter: Bob Hanson


Using TestBobHanson in GroupByTest, use a database that does not have any rows 
in Users, ApplicationUsers, ApplicationUserRoles

Change the GroupByBobHanson select statement to: (basically almost all INNER 
JOINs with LEFT JOIN)
                SELECT 
                        Applications.ApplicationId, 
Applications.ApplicationName, 
                        DefaultRole.RoleId as DefaultRoleId, 
DefaultRole.RoleName as DefaultRoleName, 
                        Users.UserId, Users.UserName,
                        Addresses.AddressId, 
                        ApplicationUsers.ActiveFlag,
                        Roles.RoleId, Roles.RoleName
                FROM   Applications 
                INNER JOIN Roles DefaultRole 
                        ON DefaultRole.RoleId = Applications.DefaultRoleId
                LEFT JOIN ApplicationUserRoles 
                        ON ApplicationUserRoles.ApplicationId = 
Applications.ApplicationId
                LEFT JOIN ApplicationUsers 
                        ON ApplicationUsers.ApplicationId = 
ApplicationUserRoles.ApplicationId AND ApplicationUsers.UserId = 
ApplicationUserRoles.UserId
                LEFT JOIN Users ON Users.UserId = ApplicationUsers.UserId
                LEFT JOIN Addresses 
                        ON Addresses.AddressId = Users.AddressId
                LEFT JOIN Roles Roles
                        ON Roles.RoleId = ApplicationUserRoles.RoleId
                WHERE  Applications.ApplicationName = 'Application Manager'

The result will be an Application with all other columns NULL.

When iBatis builds the Application object, the Users property ends up as a List 
containing a single User object. The User object is "empty" (default 
constructor is called but no other initialization takes place). In my opinion, 
iBatis should either set Users to null or, better yet, create an empty list 
(length = 0).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to