views:

19

answers:

1

Does JPA support embedding a class attribute whose type is a parameterized generic or java.lang.Object? For example:

public class Foo<T>;
{
   private T      param1;
   private Object param2;
}

I have a use case where I have a class that "wraps" some arbitrary class (the generic T or java.lang.Object) via aggregation plus contains primitive types representing metadata about the wrapped object.

In this case, I'd like there to be DB tables for each of things being wrapped that also contain columns for the metadata. These metadata columns would be duplicated across all tables representing the wrapped embedded objects.

A: 

I'd like there to be DB tables for each of things being wrapped that also contain columns for the metadata. These metadata columns would be duplicated across all tables representing the wrapped embedded objects.

You could maybe persist Object or T as a @Lob but I don't think that the above is possible, I don't see how you could express the mappings, how a JPA provider could be aware of the tables.

See also

Pascal Thivent