[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] Virtual Metlhods | questions
|
Tom,
I when I enabled the oneToOneMapping.useBasicIndirection(); I started
failing with exception
Exception [EclipseLink-60] (Eclipse Persistence Services -
2.3.2.v20111125-r10461):
org.eclipse.persistence.exceptions.DescriptorException
Exception Description: The method [_persistence_set_phoneNumber_vh] or
[_persistence_get_phoneNumber_vh] is not defined in the object
[gridcache.model.Employee].
Internal Exception: java.lang.NoSuchMethodException:
gridcache.model.Employee._persistence_get_phoneNumber_vh(java.lang.String)
Mapping: org.eclipse.persistence.mappings.OneToOneMapping[phoneNumber]
Descriptor: RelationalDescriptor(gridcache.model.Employee -->
[DatabaseTable(TLG_GC_EMPLOYEE)])
Emploee to PhoneNumber (1-1)
Below is code to create OneToOneMapping
private void oneToOneMapping(ClassDescriptor classDescriptor) {
OneToOneMapping oneToOneMapping = new OneToOneMapping();
oneToOneMapping.setDescriptor(classDescriptor);
oneToOneMapping.setCascadeAll(true);
oneToOneMapping.useBasicIndirection();
VirtualAttributeAccessor virtualAttributeAccessor2 = new
VirtualAttributeAccessor();
virtualAttributeAccessor2.setAttributeName("phoneNumber");
virtualAttributeAccessor2.setGetMethodName("get");
virtualAttributeAccessor2.setSetMethodName("set");
virtualAttributeAccessor2.initializeAttributes(classDescriptor.getJavaClass());
oneToOneMapping.setAttributeAccessor(virtualAttributeAccessor2);
oneToOneMapping.setAttributeName("phoneNumber");
oneToOneMapping.setReferenceClass(PhoneNumber.class);
oneToOneMapping.setForeignKeyFieldName("PHONE_NUMBER_ID");
Vector<String> databaseFields = new Vector<String>();
databaseFields.add("PHONE_NUMBER_ID");
oneToOneMapping.setForeignKeyFieldNames(databaseFields);
classDescriptor.getMappings().add(oneToOneMapping);
}
Employee
My set and get in the Employee class looks like
public void set(String key,Object value) {
if (PhoneNumber.class.isInstance(value)) {
ValueHolderInterface valueHolderInterface = new ValueHolder();
valueHolderInterface.setValue(value);
extensions.put(key, valueHolderInterface);
} else {
extensions.put(key, value);
}
}
public Object get(String key) {
return ValueHolderInterface.class.isInstance(extensions.get(key)) ?
ValueHolderInterface.class.cast(extensions.get(key)).getValue() :
extensions.get(key);
}
--
View this message in context: http://old.nabble.com/Virtual-Metlhods-%7C-questions-tp34172077p34173868.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.