GithubHelp home page GithubHelp logo

Comments (23)

GoogleCodeExporter avatar GoogleCodeExporter commented on May 21, 2024
The related discuss is
https://groups.google.com/group/orika-discuss/browse_thread/thread/7720d8726a432
ef6

Original comment by [email protected] on 9 Jun 2012 at 7:00

from orika.

GoogleCodeExporter avatar GoogleCodeExporter commented on May 21, 2024

Original comment by [email protected] on 9 Jun 2012 at 5:32

  • Changed state: Accepted

from orika.

GoogleCodeExporter avatar GoogleCodeExporter commented on May 21, 2024

Original comment by [email protected] on 9 Jun 2012 at 5:34

  • Added labels: Priority-High
  • Removed labels: Priority-Medium

from orika.

GoogleCodeExporter avatar GoogleCodeExporter commented on May 21, 2024
by "merge", do you mean that if a collection A is to be mapped into another B, 
you don't want existing items in B removed if there's no corresponding value in 
A?

or is it more that that values in A should be mapped into B, with the end 
result that B should only contain mapped values from A, but items that would be 
unchanged are not replaced?

what I'm trying to figure out is, if Orika avoided creating any new elements 
for a collection and instead modified in place those which already existed, 
(and removed elements which did not have a corresponding value in the source 
collection/array?), would that solve this problem?

Original comment by [email protected] on 10 Jun 2012 at 5:53

from orika.

GoogleCodeExporter avatar GoogleCodeExporter commented on May 21, 2024
if Orika avoided creating any new elements for a collection and instead 
modified in place those which already existed, and removed elements which did 
not have a corresponding value in the source collection/array. I'll be happy. 
Yes,  that solve this problem. Merger should tell Orika how to find 
corresponding values in B for values from A. New element should be created if 
merger didn't find corresponding element in the destination collection. For 
circle, B to A to B if A doesn't  be modified then B should not be modified too.

Original comment by [email protected] on 10 Jun 2012 at 8:16

from orika.

GoogleCodeExporter avatar GoogleCodeExporter commented on May 21, 2024
[deleted comment]

from orika.

GoogleCodeExporter avatar GoogleCodeExporter commented on May 21, 2024
[deleted comment]

from orika.

GoogleCodeExporter avatar GoogleCodeExporter commented on May 21, 2024
[deleted comment]

from orika.

GoogleCodeExporter avatar GoogleCodeExporter commented on May 21, 2024
In more common solution, a custom merger must map collection A to B itself, and 
only delegate to map element from A to element from B back to Orika. 
The cause of the problem is that hibernate persistent collection becoming dirty 
for any modifing. For example : 
group.getUsers().remove(user1);
group.getUsers().add(user1); // reverting state of collection
Collection of users is marked as dirty and hibernate generate excess sql update.

Original comment by [email protected] on 11 Jun 2012 at 9:17

from orika.

GoogleCodeExporter avatar GoogleCodeExporter commented on May 21, 2024
In the 1.2.0 branch, this capability can now be achieved by explicitly 
registering a custom mapper.
See the attached test case for an example which is very close to the original 
example proposed. This solution is preferable from an API standpoint, because 
it means we can reuse an existing type (CustomMapper), and my thinking is that 
this mechanism could be used to satisfy many other use cases as well.
Please see if the attached example seems acceptable for your use case...

Original comment by [email protected] on 9 Jul 2012 at 1:57

Attachments:

from orika.

GoogleCodeExporter avatar GoogleCodeExporter commented on May 21, 2024
It's nice capability, which will resolve all my problem. I look forward to 
release 1.2.*. 
Thanks a lot!

Original comment by [email protected] on 9 Jul 2012 at 8:02

from orika.

GoogleCodeExporter avatar GoogleCodeExporter commented on May 21, 2024
This capability is now available in the 1.2.0 branch.

Original comment by [email protected] on 11 Jul 2012 at 6:24

  • Changed state: Fixed

from orika.

GoogleCodeExporter avatar GoogleCodeExporter commented on May 21, 2024
I've tested  the 1.2.0 branch. Unfortunally, It doesn't work well. I need 
capability to registrate the merger for Collection<Dto> to Collection<Enrity>. 
This merger has to apply for all subclasses such as:
Collection<ChildDto> to Collection<ChildEnrity>
List<Child2Dto> to Set<ChildEnrity>
List<ChildDto> to List<ChildEnrity> 
and so on
I've added method testMergingWithCustomMapperForChildren in junit test which 
demonstrate my desire.

Original comment by [email protected] on 21 Aug 2012 at 8:51

Attachments:

from orika.

GoogleCodeExporter avatar GoogleCodeExporter commented on May 21, 2024
Ok, I've applied another fix in the 1.2.0 branch which should resolve this new 
test case.
Please verify if you get  a chance...

Original comment by [email protected] on 23 Aug 2012 at 5:24

  • Changed state: Started

from orika.

GoogleCodeExporter avatar GoogleCodeExporter commented on May 21, 2024
Thanks! But, I catch exception if I map Set<ChildDto> to Set<ChildEntity> 
(testMergingWithCustomMapperForChildrenSetToSet in attach). And MergingMapper 
must have   
the signature CustomMapper<Collection<? extends Dto>, Collection<? extends 
Entity>>, because Collection<Dto> isn't assignable from Collection<ChildDto>.

Original comment by [email protected] on 23 Aug 2012 at 8:37

Attachments:

from orika.

GoogleCodeExporter avatar GoogleCodeExporter commented on May 21, 2024
Sorry for the late response; try with the most current updates to the branch.
I've made some fixes to the way conrcrete types resolve, including automatic 
registration of some default raw concrete types for Collection, List, Set, Map 
and Map.Entry (which can be overridden as needed, of course)

Original comment by [email protected] on 28 Aug 2012 at 5:31

from orika.

GoogleCodeExporter avatar GoogleCodeExporter commented on May 21, 2024
I've  found the problems in api. Class of entity destination is unknown in 
merge. Such, the merger create instance of Entity.class instead of 
ChildEntity.class. Another problem is cast errors for generic collection. I 've 
added assertion in testMergingWithCustomMapperForChildrenSetToSet which 
demonstrate first  problem. And DesiredMergingMapper which should resolve this 
two problems.
Excuse me for slowness.

Original comment by [email protected] on 10 Sep 2012 at 8:43

Attachments:

from orika.

GoogleCodeExporter avatar GoogleCodeExporter commented on May 21, 2024
Thanks for the update, and the test case. Always helpful.
I think this may require update to the Mapper interface, since we don't 
currently have any signatures that pass the resolved Type<?> into the mapper 
(although we have it available).
We have a pending fix release 1.2.1, and I can probably look at incorporating 
it after this.

Original comment by [email protected] on 11 Sep 2012 at 7:22

from orika.

GoogleCodeExporter avatar GoogleCodeExporter commented on May 21, 2024
A fix has been applied in the current master (1.4.0-SNAPSHOT) which makes the 
resolved source and destination types available on the MappingContext, which 
could be used from your custom mapper.
Please see the attached modifications to the test case which now pass.

Original comment by [email protected] on 30 Nov 2012 at 1:51

Attachments:

from orika.

GoogleCodeExporter avatar GoogleCodeExporter commented on May 21, 2024
I've tested trunk. All work fine!  I've found small bug in 
CustomMergerTest:184, line should be  "mapperFacade.map(memberDto, 
memberEntity);" instead of  "mapperFacade.map(memberEntity, memberDto);"

Thanks a lot!

Original comment by [email protected] on 10 Dec 2012 at 12:42

from orika.

GoogleCodeExporter avatar GoogleCodeExporter commented on May 21, 2024

Original comment by [email protected] on 8 Mar 2013 at 8:59

  • Changed state: Fixed

from orika.

GoogleCodeExporter avatar GoogleCodeExporter commented on May 21, 2024
Guys, hello!
Thanks for a great project!
Unfortunately,  this issue is not completely resolved. The main idea is that 
special collections that used by hibernate (e.g. 
org.hibernate.collection.internal.PersistentBag and etc) for holding entities 
do not pass the check of the type equality with 
ma.glasnost.orika.metadata.Type.isAssignableFrom(Type<?>) on runtime. And vice 
versa if I register a special custom mapper for PersistentBag to/from 
java.util.Collection<MyEntity> it will never be applied, since there is the 
Collection<MyEntity>  field originally in parent. Please advise any workaround 
for this situation.

Original comment by [email protected] on 29 Nov 2013 at 3:26

from orika.

GoogleCodeExporter avatar GoogleCodeExporter commented on May 21, 2024
Addition to the previous comment. As I have found a moment ago, fix was broken 
between 1.4.1 and 1.4.2 releases. I mean 1.4.1 works for me, but 1.4.2 and 
1.4.3 - not. The unit test for this issue have doesn't have much in common with 
reality (since collection real implementation is different), so it works fine 
even in 1.4.3 version.
I hope it will be helpful. Thanks.

Original comment by [email protected] on 29 Nov 2013 at 3:44

from orika.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.