Last active
August 29, 2015 14:21
-
-
Save dalmat36/36b74ee59bebc241fb47 to your computer and use it in GitHub Desktop.
This is the employee class required to do the examples at http://mongodb.github.io/morphia/1.0/getting-started/quick-tour/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.mattdalesio.morphiaTesting; | |
| import java.util.ArrayList; | |
| import java.util.List; | |
| import org.bson.types.ObjectId; | |
| import org.mongodb.morphia.annotations.*; | |
| @Entity("employees") | |
| @Indexes( | |
| @Index(value = "salary", fields = @Field("salary")) | |
| ) | |
| class Employee { | |
| @Id | |
| private ObjectId id; | |
| private String name; | |
| @Reference | |
| private Employee manager; | |
| @Reference | |
| private List<Employee> directReports = new ArrayList<Employee>(); | |
| @Property("wage") | |
| private Double salary; | |
| public Employee(){ | |
| } | |
| public Employee(String name, double salary) { | |
| this.name = name; | |
| this.salary = salary; | |
| } | |
| @Override | |
| public String toString() { | |
| return "Employee [id=" + id + ", name=" + name + ", manager=" + manager | |
| + ", directReports=" + directReports + ", salary=" + salary | |
| + "]"; | |
| } | |
| public List<Employee> getDirectReports() { | |
| return directReports; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment