Doctrine\Tests\Models\CMS\CmsUser:
  type: entity
  table: cms_users
  namedQueries:
    all: SELECT u FROM __CLASS__ u
  namedNativeQueries:
    fetchIdAndUsernameWithResultClass:
      resultClass: CmsUser
      query: SELECT id, username FROM cms_users WHERE username = ?
    fetchAllColumns:
      name: fetchAllColumns
      resultClass: CmsUser
      query: SELECT * FROM cms_users WHERE username = ?
    fetchJoinedAddress:
      name: fetchJoinedAddress
      resultSetMapping: mappingJoinedAddress
      query: SELECT u.id, u.name, u.status, a.id AS a_id, a.country, a.zip, a.city FROM cms_users u INNER JOIN cms_addresses a ON u.id = a.user_id WHERE u.username = ?
    fetchJoinedPhonenumber:
      name: fetchJoinedPhonenumber
      resultSetMapping: mappingJoinedPhonenumber
      query: SELECT id, name, status, phonenumber AS number FROM cms_users INNER JOIN cms_phonenumbers ON id = user_id WHERE username = ?
    fetchUserPhonenumberCount:
      name: fetchUserPhonenumberCount
      resultSetMapping: mappingUserPhonenumberCount
      query: SELECT id, name, status, COUNT(phonenumber) AS numphones FROM cms_users INNER JOIN cms_phonenumbers ON id = user_id WHERE username IN (?) GROUP BY id, name, status, username ORDER BY username
    fetchMultipleJoinsEntityResults:
      name: fetchMultipleJoinsEntityResults
      resultSetMapping: mappingMultipleJoinsEntityResults
      query: SELECT u.id AS u_id, u.name AS u_name, u.status AS u_status, a.id AS a_id, a.zip AS a_zip, a.country AS a_country, COUNT(p.phonenumber) AS numphones FROM cms_users u INNER JOIN cms_addresses a ON u.id = a.user_id INNER JOIN cms_phonenumbers p ON u.id = p.user_id GROUP BY u.id, u.name, u.status, u.username, a.id, a.zip, a.country ORDER BY u.username

  sqlResultSetMappings:
    mappingJoinedAddress:
      entityResult:
        0:
          entityClass: __CLASS__
          fieldResult:
            0:
              name: id
            1:
              name: name
            2:
              name: status
            3:
              name: address.zip
            4:
              name: address.city
            5:
              name: address.country
            6:
              name: address.id
              column: a_id
    mappingJoinedPhonenumber:
      name: mappingJoinedPhonenumber
      entityResult:
        user:
          entityClass: CmsUser
          fieldResult:
            0:
              name: id
            1:
              name: name
            2:
              name: status
            3:
              name: phonenumbers.phonenumber
              column: number
    mappingUserPhonenumberCount:
      name: mappingUserPhonenumberCount
      columnResult:
        0:
          name: numphones
      entityResult:
        user_0:
          entityClass: CmsUser
          fieldResult:
            0:
              name: id
            1:
              name: name
            2:
              name: status
    mappingMultipleJoinsEntityResults:
      name: mappingMultipleJoinsEntityResults
      columnResult:
        0:
          name: numphones
      entityResult:
        0:
          entityClass: __CLASS__
          fieldResult:
            0:
              name: id
              column: u_id
            1:
              name: name
              column: u_name
            2:
              name: status
              column: u_status
        1:
          entityClass: CmsAddress
          fieldResult:
            0:
              name: id
              column: a_id
            1:
              name: zip
              column: a_zip
            2:
              name: country
              column: a_country
  id:
    id:
      type: integer
      generator:
        strategy: AUTO
  fields:
    name:
      type: string
      length: 255
    username:
      type: string
      length: 255
      unique: true
    status:
      type: string
      length: 50
      unique: true
  oneToOne:
    address:
      targetEntity: CmsAddress
      orphanRemoval: true
      inversedBy: user
      joinColumn:
        name: address_id
        referencedColumnName: id
      cascade: [ persist ]
    email:
      targetEntity: CmsEmail
      orphanRemoval: true
      inversedBy: user
      joinColumn:
        nullable: true
        referencedColumnName: id
      cascade: [ persist ]
  manyToMany:
    groups:
      targetEntity: CmsGroup
      joinTable:
        name: cms_users_groups
        joinColumns:
          user_id:
            referencedColumnName: id
        inverseJoinColumns:
          group_id:
            referencedColumnName: id
      cascade: [ persist , detach, merge]
