Dynamic JPA and AttributeOverrides [message #804538] |
Wed, 22 February 2012 13:49  |
Eclipse User |
|
|
|
I am using Dynamic JPA Api and would like to know how to use "AttributeOverrides" (or equivalent of) on an embedded type.
For e.g I have a type "Employee" having two attributes of embedded type "MyType".
Employee {
@Embedded
public MyType t1;
@AttributeOverrides({
@AttributeOverride(name = "DBCOL"})
@Embedded
public MyType t2;
}
I was able to create the embedded type mapping using "addAggregateObjectMapping" but havent found way to override the database mapping using Dynamic API.
Is this possible in Dynamic JPA ?
|
|
|
|
Re: Dynamic JPA and AttributeOverrides [message #809821 is a reply to message #808359] |
Wed, 29 February 2012 04:50   |
Eclipse User |
|
|
|
Thanks for your response.I tried using the approach but it looks like the overridden mapping specified via "addFieldNameTranslation"is being ignored .
In the code below Iam expecting "EMD_ATTR2.JsonString" to use the db mapping "db_jsonstring_2" but it reverts to "db_jsonstring".
//////START CODE
configureEmbeddable(emdType);
....
dynType.addAggregateObjectMapping("EMD_ATTR", emdType.getType(), false);
AggregateObjectMapping mapping = dynType.addAggregateObjectMapping("EMD_ATTR2", emdType.getType(), false);
mapping.addFieldNameTranslation("db_jsonstring_2","JsonString") ; //overriding here
private static void configureEmbeddable(JPADynamicTypeBuilder emdType) {
emdType.addDirectMapping("Data_Type", String.class, "db_data_type");
emdType.addDirectMapping("JsonString", String.class, "db_jsonstring");
}
/////////END CODE
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.06368 seconds