Database Reference
In-Depth Information
Listing 11-57.
The
MappedProductUserPurchase
Interface
@QueryResult
@NodeEntity
public interface
MappedProductUserPurchase
{
@ResultColumn("productId")
String getProductId();
@ResultColumn("title")
String getTitle();
@ResultColumn("fullname")
List<String> getFullname();
@ResultColumn("wordPhrase")
String getWordPhrase();
@ResultColumn("cfriends")
Integer getCfriends();
}
Products Purchased by Friends
To get all of the products that have been purchased by friends, the
friendsPurchase
method is called from
PurchaseImpl
, which then makes use of the
friendsPurchase
in the
MappedProductUserPurchaseRepository
. The
getProductsPurchasedByUsersFriends
is shown in Listing 11-58.
The query in
getProductsPurchasedByUsersFriends
finds the users being followed by the current user and
then matches those users to a purchase that has been
MADE
which
CONTAINS
a product. The return value is a set of
properties that identify the product title and the name of the friend or friends, as well the number of friends who have
bought the product. The result is ordered by the number of friends who have purchased the product and then by
product title, as shown in Figure
11-18
.