| Dynamic JPA and AttributeOverrides [message #804538] |
Wed, 22 February 2012 13:49  |
Sunil Varma Messages: 5 Registered: February 2012 |
Junior Member |
|
|
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   |
Sunil Varma Messages: 5 Registered: February 2012 |
Junior Member |
|
|
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
|
|
|
|
|
| Re: Dynamic JPA and AttributeOverrides [message #813714 is a reply to message #810908] |
Mon, 05 March 2012 11:29   |
James Sutherland Messages: 1844 Registered: July 2009 |
Senior Member |
|
|
This does work in general, but I'm not sure how the Dynamic support initializes the descriptors.
Ensure you define the parent and child descriptors together.
There could be an issue with how Dynamic JPA does initialization, which you may wish to log a bug on.
Does it work if you use an orm.xml instead of the API?
James : Wiki : Book : Blog
|
|
|
|
Powered by
FUDForum. Page generated in 0.02146 seconds