Accessing properties of the dependent entity

Unlike SQL, the result of an entity query contains instances of the primary entity, not composite table rows with columns. Explicitly specifying a join by using the join or outerJoin methods does not change how you access properties of the dependent entity. Information from joined entities generally is not included in results. If the foreign key is on the left, you can access properties from the dependent entity by using dot notation. However, if the foreign key is on the right, you cannot use dot notation to traverse from primary instances on the left to related instances on the right.

Dependent entity with the foreign key on the left

The following Gosu code has the foreign key on the left. The primary entity type, Company, has a foreign key, PrimaryAddress, which relates to the dependent entity type, Address. You can use dot notation to access the properties of Address.
uses gw.api.database.Query

var queryCompany = Query.make(Company) 
queryCompany.join(Company#PrimaryAddress)

// Fetch the data with a for loop. 
var result = queryCompany.select()
for (company in result) {
  print (company + ", " + company.PrimaryAddress.City)
}

Dependent entity with the foreign key on the right

The following Gosu code has the foreign key on the right. You can determine that a user updated addresses, but not which addresses were updated. You cannot use dot notation to retrieve information from the Address entity rows. This limitation does not affect processing the results of inner queries with foreign keys on the right if you need no information from the related instances that produced the result. If you do want to access the information, for example to display on a screen or in a report, you must use a row query.
uses gw.api.database.Query

// -- Query the User entity --
var queryUser = Query.make(User)

// -- Select only User instances who last updated addresses in the city of Chicago --
var tableAddress = queryUser.join(Address#UpdateUser)

// -- Fetch the User instances with a for loop and print them --
var result = queryUser.select()

for (user in result) {
  print (user.DisplayName)
}