jsr338-experts@jpa-spec.java.net

[jsr338-experts] Re: Standardized Access to ChangeSet

From: Pinaki Poddar <ppoddar_at_us.ibm.com>
Date: Tue, 21 Jun 2011 09:36:59 -0700

> +1 because of power. I like my idea better because of usability.
> However - perfectly fine with the enum.

Explicit API in the form of EntityManager#get<State>Entities() will
   a) broaden the interface
   b) more importantly will not support combination of states (e.g. you
want all at least once flushed but now dirtied again objects). That is to
say, the life cycle states are not mutually exclusive.

  Besides EnumSet other alternatives to pass the intended life cycle
states are

a) variable arguments

         <T> Set<T> getEntities(Class<T> entityType, boolean
includeSubclasses, LifeCycleState... states);

b) bit mask i.e. define life cycle states as integer bits

         <T> Set<T> getEntities(Class<T> entityType, boolean
includeSubclasses, int stateBitMask);
 


The criticality of the contract is 'livliness' of the returned set.

As long as the expectation is that the members of the returned set are
valid only at the point of invocation, the contract could be met with
strong warranty.

Regards --

Pinaki Poddar
Apache OpenJPA Project Chair http://openjpa.apache.org/
JPA Expert Group Member
Application & Integration Middleware








From: Adam Bien <abien_at_adam-bien.com>
To: jsr338-experts_at_jpa-spec.java.net
Date: 06/21/11 04:52 AM
Subject: [jsr338-experts] Re: Standardized Access to ChangeSet



+1 because of power. I like my idea better because of usability.
However - perfectly fine with the enum.

On 20.06.2011, at 19:48, Pinaki Poddar wrote:

Hi,
   Useful suggestion, semantically.

  Syntactically, How about the following:
  

   /**
   * User visible persistent states of an entity.
   */
   public enum LifeCycleState {NEW, DIRTY, CLEAN, DELETED};

/**
  * Gets the persistent types whose instances are in any of the given
lifecycle states in this context.
  */
Set<Class<?>> meta = EntityManager#getClasses(EnumSet<LifyCycleState>
states);
  

/**
  * Gets the persistent entities that are in any of the given lifecycle
states in this context.
  */
 Set<Object> instances = EntityManager#getEntities(EnumSet<LifyCycleState>
states, Class<?> classes);



Regards --

Pinaki Poddar
Apache OpenJPA Project Chair http://openjpa.apache.org/
JPA Expert Group Member
Application & Integration Middleware








From: Adam Bien <abien_at_adam-bien.com>
To: jsr338-experts_at_jpa-spec.java.net
Date: 06/19/11 01:20 AM
Subject: [jsr338-experts] Re: Standardized Access to ChangeSet



Hi Werner,

I searched in the proposal and in the mailing lists but couldn't find
anything similar.

I'm happy with another solution as well.

adam
On 18.06.2011, at 13:48, Werner Keil wrote:

> Why the different name pattern for the last proposed?
> They would all fulfill the same purpose.
>
> Cheers,
> Werner
>
> -------- Original-Nachricht --------
>> Datum: Sat, 18 Jun 2011 13:06:03 +0200
>> Von: Adam Bien <abien_at_adam-bien.com>
>> An: jsr338-experts_at_jpa-spec.java.net
>> Betreff: [jsr338-experts] Standardized Access to ChangeSet
>
>> HI All,
>>
>> I would like to propose additional EntityManager methods:
>>
>> Set<Class> updated = EntityManager#getUpdatedEntities(Class<T>.class);
>> Set<Class> deleted = EntityManager#getDeletedEntities(Class<T>.class);
>> Set<Class> created = EntityManager#getCreatedEntities(Class<T>.class);
>> Set<Class> dirty = EntityManager#getDirty(Class<T>.class);
>>
>> We had to use provider-specific EntityManager extensions to access the
>> dirty entities for the implementation of replication or historization.
>>
>> Such methods would be also useful for debugging purposes,
>>
>> thanks in advance,
>>
>> adam
>>
>>
>
> --
> NEU: FreePhone - kostenlos mobil telefonieren!
> Jetzt informieren: http://www.gmx.net/de/go/freephone