UnitOfWork::newEntityBuilderWithState() ?

7 views
Skip to first unread message

Paul Merlin

unread,
Mar 24, 2015, 10:31:31 AM3/24/15
to qi4j...@googlegroups.com
Gents,

Like we have Module::newValueBuilderWithState(...)
I'd like to add UnitOfWork::newEntityBuilderWithState(...)

I have a working implementation on disk that reuse some of the facilities introduced when
Module::newValueBuilderWithState(...) was added and enhance BuilderEntityState.

The only API change is the method addition in UnitOfWork. Every other changes are in runtime.

Based on this I added an EntityToValue service to the 'conversion' library that allows to easily create new Entities or update existing Entities using state from a Value that share the same state definition (~@Unqualified).

What would you think of such an addition?
Would that be ok for you?

/Paul

Niclas Hedhman

unread,
Mar 24, 2015, 1:16:37 PM3/24/15
to Paul Merlin, qi4j...@googlegroups.com

Remind me with a small example how this is supposed to work in app code...

// Niclas

--
You received this message because you are subscribed to the Google Groups "qi4j-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qi4j-dev+u...@googlegroups.com.
To post to this group, send email to qi4j...@googlegroups.com.
Visit this group at http://groups.google.com/group/qi4j-dev.
For more options, visit https://groups.google.com/d/optout.



--
Niclas Hedhman, Software Developer
http://www.qi4j.org - New Energy for Java

Paul Merlin

unread,
Mar 24, 2015, 1:23:47 PM3/24/15
to Niclas Hedhman, qi4j...@googlegroups.com
Niclas Hedhman a écrit :
> Remind me with a small example how this is supposed to work in app code...
Sure.

In the same vein as Module::newValueBuilderWithState(..),
UnitOfWork::newEntityBuilderWithState(..) take Functions that provide
state to the Builder.

Here is some application pseudo-code using the new method:

Function<?,?> properties, associations, manyAssociations,
namedAssociations;
// ... Snip Functions creation
try( UnitOfWork uow = module.currentUnitOfWork() )
{
EntityBuilder<MyEntityType> builder = uow.newEntityBuilderWithState(
MyEntityType.class,
properties, associations, manyAssociations, namedAssociations
);
MyEntityType entity = builder.newInstance();
uow.complete();
}


Niclas Hedhman

unread,
Mar 24, 2015, 2:00:15 PM3/24/15
to Paul Merlin, qi4j...@googlegroups.com

I must have missed that completely before.

Sure, I have no direct objections. 

Why is it Functions?



  }


--
You received this message because you are subscribed to the Google Groups "qi4j-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qi4j-dev+u...@googlegroups.com.
To post to this group, send email to qi4j...@googlegroups.com.
Visit this group at http://groups.google.com/group/qi4j-dev.
For more options, visit https://groups.google.com/d/optout.

Paul Merlin

unread,
Mar 25, 2015, 5:13:20 AM3/25/15
to Niclas Hedhman, qi4j...@googlegroups.com
Niclas Hedhman a écrit :
> I must have missed that completely before.
>
> Sure, I have no direct objections.
>
> Why is it Functions?
Can't recall. It is Functions on the ValueBuilderFactory interface so I
built it with Functions for Entities too. For the sake of consistency.

In fact, the newValueBuilderWithState(..) implementation internally use
an interface defined in runtime to wrap the Functions:
ValueStateModel.StateResolver. My implementation for Entities reuse this
inner interface so it should be moved out of ValueStateModel (in
org.qi4j.runtime.composite?).

I propose to start with minimum API changes, that is only add the new
method in UnitOfWork, so I can push it to the develop branch for
inclusion in 2.1.

For 3.0 I plan to propose some refactoring around State that would get
us uniform State handling accross Composites and easier/simpler
(de)serialization.

WDYT?

/Paul

Niclas Hedhman

unread,
Mar 25, 2015, 5:57:58 AM3/25/15
to Paul Merlin, qi4j...@googlegroups.com

Sounds good..

--
You received this message because you are subscribed to the Google Groups "qi4j-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qi4j-dev+u...@googlegroups.com.
To post to this group, send email to qi4j...@googlegroups.com.
Visit this group at http://groups.google.com/group/qi4j-dev.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages