What will be grails GORM criteria below's SQL
Orders table:
- OrderID
- CustomerID
- OrderDate
Customer table:
- CustomerID
- CustomerName
- ContactName
- Country
Notice that the "CustomerID" column in the "Orders" table refers to the "CustomerID" in the "Customers" table. The relationship between the two tables above is the "CustomerID" column. Then, we can create the following SQL statement (that contains an INNER JOIN), that selects records that have matching values in both tables:strong text
SELECT Orders.OrderID, Customers.CustomerName, Orders.OrderDate
FROM Orders
INNER JOIN Customers ON Orders.CustomerID=Customers.CustomerID;
the Sql will produce those data with those column
- OrderID
- CustomerName
- OrderDate
GORM MODEL:
class Order{
Long orderId
Long customerId
def orderDate
}
class Customer{
Long customerID
Long customerName
def contactName
def country
}