Skip to content

Instantly share code, notes, and snippets.

@dalmat36
Last active August 29, 2015 14:21
Show Gist options
  • Select an option

  • Save dalmat36/36b74ee59bebc241fb47 to your computer and use it in GitHub Desktop.

Select an option

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/
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