[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] dynamic columns & maps?
|
Hi Bryan,
i am really interested in this topic also.. One of the EclipseLink
lead developers have posted an awesome example http://wiki.eclipse.org/Eclipselink/Examples/JPA/Dynamic
that you might be interested in...
cheers,
-lachlan
On 16/07/2008, at 7:58 AM, Bryan Hunt wrote:
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:
SELECT * FROM FOOS WHERE ERROR = 'Fatal Error'
for(Foo foo : foos)
System.out.println(foo.getAttributes().get("ERROR")); // Will print
"Fatal Error"
Can JPA / EclipseLink handle this use-case?
Bryan
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users