7

In my mapdb application, for example, I have a simple domain object Course:

import java.io.Serializable;

class Course implements Serializable {
  private static final long serialVersionUID = 1L;
  String cID;
  String name;
  String teacherName;
  String departmentName;
  public Course(String name) {
    this.name = name;
    System.out.println("Update: added course \"" + name);
  }
}

By trial and error I added the implements Serializable, the serialVersionID and my own domain key, cID. All seems to work. But here's my code to store that into MapDB:

NavigableMap<String, Course> courses;
courses = db.treeMap("courses", Serializer.STRING, Serializer.JAVA).createOrOpen();

Which gives a warning:

Type safety: The expression of type BTreeMap needs unchecked
conversion to conform to NavigableMap<String,Course>

I don't understand that error, but I believe it has to do with my serialization as Serializer.JAVA. What is going on, or what I am doing wrong?

halfer
  • 19,824
  • 17
  • 99
  • 186
pitosalas
  • 10,286
  • 12
  • 72
  • 120

1 Answers1

0

Add generics to treemap method:

     courses = db.<String, Course>treeMap
Jan Kotek
  • 1,084
  • 7
  • 4