Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Fetch original state of the object

Hi James,

   I was on holiday so couldn't look into your reply.

   Creating MyAttributeChangeListner (extending AttributeChangeListner) I
was able to hold onto the old values.
  Few more questions

  1) How can I tell eclipselink to start weaving MyAttributeChangeListner
into the jpa entities rather than default AttributeChangeListner.

 2) How can I get the new jpa entities from the unit of work
(RepeatbleUnitOfWork)? (in insert/update use cases)

Reason for above questions
  I an constructing annotation driven validation framework for eclipselink
for my project. My validation are fired from the aspect which can weaved
around the crud service and validation parsing info is constructed at
deployment time. The validation framework exploits apache common bean
validations + valang + spring validation framework + groovy script (or any
pluggable script like MVEL)
Note :- no proxy is created around the JPA entities.
Examples
// Spring validators
@OhiBusinessRule(name = "Relation Validations", beforeInsUpdValidators = {
		GenericDynamicFieldsValidator.class, RelationValidator.class })

// valang
@OhiBusinessRule(name = "valangRules",
                     rulesBefore = { "dynamicFieldUsage.fieldUsageName :
upper(?) = TRUE: 'dynamicFieldUsage.fieldUsageName is not in upper case' :
'errors.dfusFieldUsageName'",
                                     "dynamicFieldUsage.inLov : ? = TRUE :
'Indication lov is not True' : 'errors.indInLov'" },
                     valangFunctions = { Upper.class })

//  groovy
@OhiBusinessRule(name = "groovyRules",
                     rulesBefore = { "relation.name != null: 'relation name
cannot be null' : 'errors.relation.name'})


    

Regards,
Gaurav Malhotra
Oracle


Gaurav Malhotra wrote:
> 
> Hi,
> 
>   I want to write attribute change validation rules. I gathered that
> eclipse link automatically weave change tracker into the jpa entities + it
> uses AttributeChangeTrackingPolicy (by default), hence keep the clone of
> the original object.
> Pre - condition :- Weaving should be enabled.
>    (Please validate my understanding)
> 
>   How can I get the original state of the object. By original state I mean
> state of object before the update chnages were applied.
> 
>   AttributeChangeListner acl = (  AttributeChangeListner)
> (((ChanageTracker) xxxx)._persistence_getPropertyChangeListener())
> 
>   Now how to get the original state of the object???
> 
> Regards,
> Gaurav Malhotra
> 

-- 
View this message in context: http://www.nabble.com/Fetch-original-state-of-the-object-tp24488730p24594410.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top