Database Reference
In-Depth Information
Listing 9.1. Initial POJO modeling attempt
There is nothing too complicated here—this is basic object modeling. Both the
User
and
Movie
concepts have been modeled as first-class entities—that seems reasonable enough.
You'vealsomodeledauser'sviewingofaparticularmovieasanentityaswell,namelythe
Viewing
class. This is primarily because the relationship itself holds important inform-
ation that you want to retain and use—namely the
stars
rating provided by the user. If
you had modeled this as a simple collection type relationship between
User
and
Movie
,
you'd lose this information.
At this point there is still no reference to any SDN- or Neo4j-specific concepts, just POJO
stuff. Next, you'll need to map this entity into the underlying Neo4j graph model.
How close have you gotten to creating a POJO model that's easily translatable into the
Neo4jworld?Canyouuseitasis,ordoesitneedanymodifications?Inthisparticularcase
you appear to have a good fit, with the
User
and
Movie
classes mapping neatly into the
Neo4jnodesprimitiveconceptwithanassociated
name
and
title
property,respectively.