Skip to main content

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

This is a area of interest for me. There are several approaches to dynamic models including:

1. Building the dynamic nature into the static model using a map of additional properties

2. Building the dynamic attributes into the model with undefined attributes and columns in the models that will be given meaning at runtime.

3. Generating the entity class dynamically based on metadata (as illustrated in the example link below)

4. Combination of static models with dynamic/load-time weaving to add additional attributes

This area is a bit of a pet-project of mine. I have internal consumers of TopLink/EclipseLink within Oracle building applications that are end-user customized and therefore require a solution for customizing dynamic properties without requiring a development phase to alter the class structure, its mappings and the underlying schema. These are typically customizations done during application install or in some cases more dynamically during runtime through an admin client.

If you are interested in working through various solutions I can setup some more information on the wiki to get us started and then gather additional use-cases and work through some sample code for each to case.

Doug 

-----Original Message-----
From: Lachlan Gregor [mailto:lachlan.gregor@xxxxxxxxx]
Sent: Friday, July 18, 2008 2:35 PM
To: EclipseLink User Discussions
Subject: 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

_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


Back to the top