ActiveJdbc unable to include the table

60 views Asked by At

I have two tables orders and address

Order table
+----+----------------+-----------------------------------+--------------------------------------------------+
| id | trackingNumber | user_id (reference to user table) | receiverAddress_id (reference to address table ) |
+----+----------------+-----------------------------------+--------------------------------------------------+
| 1  | TRACK123       | 1                                 | 2                                                |
+----+----------------+-----------------------------------+--------------------------------------------------+
|    |                |                                   |                                                  |
+----+----------------+-----------------------------------+--------------------------------------------------+
address table
+----+--------+--------------+--------------+
| id | name   | addressLine1 | addressLine2 |
+----+--------+--------------+--------------+
| 1  | Mr.abc | qwertyuiop   | qwertyuiop   |
+----+--------+--------------+--------------+
|    |        |              |              |
+----+--------+--------------+--------------+

Need help in activeJdbc joining these two tables and get address as the children in JSON. I have tried the relation annotatins however unable to get the desired result.

//sample code: not working
  LazyList<Orders> order = Orders.find("id = 1").include(Addresses.class);
  order.toJson(true);

0

There are 0 answers