Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] dynamic columns & maps?

I have an interesting use-case involving what I call dynamic columns and maps. Consider the following class:

public void Foo
  private long id;
  private String name;
  private ...
  private HashMap<String, Object> attributes;

The objects stored in the map are basic types you can store in a database column such as Integer, String, Timestamp, etc. I'd like to persist instances of Foo into a database table where each key of the attribute map corresponds to the name of a column in the table. The set of keys, along with the type of data stored, is specified by a user-defined configuration and can change over the life of the project. I also need to do queries against those key, value pairs and have instances of Foo returned from the database. For example:


for(Foo foo : foos)
System.out.println(foo.getAttributes().get("ERROR")); // Will print "Fatal Error"

Can JPA / EclipseLink handle this use-case?


Back to the top