FramedGraph mapping between (Tinkerpop) DAO objects to model objects

72 views Asked by At

I am using OrientDb 2.2 and the TinkerPop FramedGraph. I am using FramedGraph for the ease with which I interact with object models instead of doing setProperty("name", "bob")

One thing that I dont understand with FramedGraph is why do I have interface DAO objects that cant be implemented? Due to the above constrained I have duplication of objects: tinkerpop DAO interface and model objects.

interface UserNode { private String firstName; private String lastName; }

class User { private String firstName; private String lastName; }

This arises major overheads when writing to and reading back large chunks of data.

List<User> fetchAllUsers() { Iterable<UserNode> userNodes = graph.query().vertices(UserNode.class); List<User> users = new ArrayList<>(); for (UserNode userNode: userNodes) { User user = new User(); user.setFirstName(userNode.getFirstName()); user.setLastName(userNode.getLastName()); users.add(user); } }

Is there a way to avoid the above inefficiency?

0

There are 0 answers