I suppose if I were able to dynamically create "Property" classes which
reference a specific Entity class, then I might be able to simulate this..
During runtime, if I see a "new" field for an existing Entity, I'd
generate a new Property class having the appropriate fields and let
OpenJPA create the new backing SQL table for me. Supporting bytecode for
the new Property class would likely have to be saved somehow, or else it
would have to be regenerated via database introspection on startup.
Andy
Andy Schlaikjer wrote:
It's actually a bit easier for me to describe the database schema than
the api, so I'll start with that;
I'd like a primary entity table to store all "fixed" fields for the
entity, along with primary key. Any "dynamic" entity fields would
generate separate tables which might look like:
Table name: <name of entity>_<name of field>
Column 1: foreign key to entity table
Column 2: field value
Column 2 type: defined in terms of field type
(indices defined as needed)
Of course, if the dynamic field type were something more complex than a
basic type, then this organization would have to be extended somehow..
Andy
Patrick Linskey wrote:
Can you describe what you're looking for in more detail, both in terms
of the database schema and the Java APIs?
-Patrick
On Tue, Feb 26, 2008 at 9:44 AM, Andy Schlaikjer <[EMAIL PROTECTED]>
wrote:
On a somewhat related note, I'm interested in using column stores for
entities with arbitrary, typed attributes, but not sure how I might
structure this in JPA. Any thoughts?
Andy
Patrick Linskey wrote:
> Hi,
>
> In Java SE, this is trivial: simply do not list persistent types,
> jars, or mapping files in your persistence.xml file. Dynamic class
> loading is discussed in the docs [1].
>
> It would be nice to add an API to register new classes even when
other
> types are listed in persistence.xml; the underlying capability
exists,
> but the product does not have such an explicit API.
>
> -Patrick
>
> [1]
http://openjpa.apache.org/docs/latest/manual/ref_guide_pc.html#ref_guide_pc_pcclasses
>
> On Sun, Feb 24, 2008 at 2:10 AM, cws <[EMAIL PROTECTED]> wrote:
>> brief: I want to add an unknown entity to my running PU in JavaSE.
>>
>> My JavaSE client app needs to load new, unknown entities
(classes, not
>> objects) from a trusted URLClassLoader. I would like to add
these new
>> entities to the existing PU, but this doesn't seem possible in SE
>> without changing the persistence.xml and restarting. As a
kludge I can
>> send a persistence.xml with the class and create a new PU, but that
>> doesn't allow interaction with unknown entities in the existing PU.
>>
>> I believe the spec requires all classes to be known at start,
but I'm
>> hoping OpenJPA or something else has implemented this dynamic
>> feature(?). Are there any established workarounds for the
client here?