Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Virtual Metlhods | questions

Guy,
 When is do oneToOneMapping.useBasicIndirection(). then the eclipselink
deployment fails complaining about the value holder. The below is the
exception trace
Exception [EclipseLink-60] (Eclipse Persistence Services -
2.3.2.v20111125-r10461):
org.eclipse.persistence.exceptions.DescriptorException
Exception Description: The method [_persistence_set_phoneNumbers_vh] or
[_persistence_get_phoneNumbers_vh] is not defined in the object
[gridcache.model.Employee].
Internal Exception: java.lang.NoSuchMethodException:
gridcache.model.Employee._persistence_get_phoneNumbers_vh(java.lang.String)
Mapping: org.eclipse.persistence.mappings.OneToManyMapping[phoneNumbers]
Descriptor: RelationalDescriptor(gridcache.model.Employee -->
[DatabaseTable(TLG_GC_EMPLOYEE)])

Exception [EclipseLink-127] (Eclipse Persistence Services -
2.3.2.v20111125-r10461):
org.eclipse.persistence.exceptions.DescriptorException
Exception Description: The get method for the attribute [phoneNumbers] does
not return a ValueHolderInterface, but the mapping uses indirection.
Mapping: org.eclipse.persistence.mappings.OneToManyMapping[phoneNumbers]
Descriptor: RelationalDescriptor(gridcache.model.Employee -->
[DatabaseTable(TLG_GC_EMPLOYEE)])

Exception [EclipseLink-129] (Eclipse Persistence Services -
2.3.2.v20111125-r10461):
org.eclipse.persistence.exceptions.DescriptorException
Exception Description: The set method for the attribute [phoneNumbers] does
not take a ValueHolderInterface as its parameter, but the mapping uses
indirection.
Mapping: org.eclipse.persistence.mappings.OneToManyMapping[phoneNumbers]
Descriptor: RelationalDescriptor(gridcache.model.Employee -->
[DatabaseTable(TLG_GC_EMPLOYEE)])

Regarding Read/WriteTransformer >>>> Yes, in the virtual methods we get Map
of attributes. My use case is to give the customer "Value Object". So I was
hopping, I could perform that transformation using eclipselink way.



Guy Pelletier wrote:
> 
> Gaurav,
> 
> To use indirection set:
> 
> oneToOneMapping.useBasicIndirection()
> 
> Also, read and write transformers are used and specified on a 
> TransformationMapping. Not sure I completely understand your question 
> and their usage with the attribute accessor. The accessor is used to 
> retrieve the value from the object into the mapping. The mapping can 
> then apply any transformations or conversions. When using a 
> DirectToFieldMapping you could use a converter on the mapping.
> 
> Cheers,
> Guy
> 
> On 17/07/2012 3:39 AM, Gaurav Malhotra wrote:
>> Hi All, I am trying to specify DirectToFieldMapping, OneToMapping and 
>> OneToManyMapping in the session customizer. Let's take a example of 
>> OneToOneManyMapping . I am setting up the OneToOneMapping as follows. 
>> Currently I am specifying "do not use indirection". Is it possible to 
>> specify - IndirectionPolicy and make sure the relationship uses 
>> ValueHolder (lazy initialization). I will be great if somebody can 
>> point me to sample code to achieve this.I want to programatically 
>> weave in the lazy loading value holder code. private void 
>> oneToOneMapping(ClassDescriptor classDescriptor) { OneToOneMapping 
>> oneToOneMapping = new OneToOneMapping(); 
>> oneToOneMapping.setDescriptor(classDescriptor); 
>> oneToOneMapping.setCascadeAll(true); 
>> *oneToOneMapping.dontUseIndirection();* 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"); 
>> VectordatabaseFields = new Vector(); 
>> databaseFields.add("PHONE_NUMBER_ID"); 
>> oneToOneMapping.setForeignKeyFieldNames(databaseFields); 
>> classDescriptor.getMappings().add(oneToOneMapping); } Another question 
>> ============= Is it possible to specify Reader/WriterTrasnformer with 
>> VirtualMethods. That is, to apply Reade/WriteTransformer to the 
>> attributes in the extension Map. NOTE > In my use case, extension 
>> attributes can be DirectToFieldMapping/OneToOne/OneToMany attributes 
>> which I am making it programatically in the session customization 
>> phase. ~GM
>> ------------------------------------------------------------------------
>> View this message in context: Virtual Metlhods | questions 
>> <http://old.nabble.com/Virtual-Metlhods-%7C-questions-tp34172077p34172077.html>
>> Sent from the EclipseLink - Users mailing list archive 
>> <http://old.nabble.com/EclipseLink---Users-f26658.html> at Nabble.com.
>>
>>
>> _______________________________________________
>> eclipselink-users mailing list
>> eclipselink-users@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
> 
> -- 
> 
> Oracle <http://www.oracle.com>
> Guy Pelletier
> 
> ORACLE Canada, 45 O'Connor Street Suite 400 Ottawa, Ontario Canada K1P 1A4
> Green Oracle <http://www.oracle.com/commitment> Oracle is committed to 
> developing practices and products that help protect the environment
> 
> 
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
> 
> 
-- 
View this message in context: http://old.nabble.com/Virtual-Metlhods-%7C-questions-tp34172077p34173587.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top