Thanks Dan!

I'll give it a try when I am back at the office.

Regars,

Minto

PS. Regarding code formatting I prefer my own formatting (me being
stubborn ;-) which is consistent over my isis and not isis projects. But
thanks for the tip anyways. To reduce boilerplate (getters and setters)
I mostly use Lombok.

Op 22-9-2012 9:05, Dan Haywood schreef:
> Aha!  Have found the problem.  It's a good one.
> 
> The problem was that DataNucleus didn't seem to have replaced the Parent's
> ArrayList with its own RDBMS-aware equivalent:
> 
>   @Persistent(mappedBy="parent")
>   private final List<Child> children = new ArrayList<Child>();
> 
> And the reason for that is "final".
> 
> So, instead, this should read:
> 
>   @Persistent(mappedBy="parent")
>   private List<Child> children = new ArrayList<Child>();
> 
> 
> Fixing this then discovered a second issue.  JDO/DataNucleus gives us
> persistence-by-reachability.  In the addChild() method, you had:
> 
>   public void addChild( @Named("Name") String name ) {
>     final Child child = newTransientInstance(Child.class);
>     child.setName(name);
>     addToChildren(child);
>     persist(child);
>   }
> 
> However, attaching the child to the parent will cause it to be persisted,
> and then calling persist() once again makes Isis throw an exception.  So, I
> changed the code to:
> 
>   public void addChild( @Named("Name") String name ) {
>     final Child child = newTransientInstance(Child.class);
>     child.setName(name);
>     addToChildren(child);
>     persistIfNotAlready(child);
>   }
> 
> and it worked.
> 
> This might indicate a slight inconsistency in the OS implementations.  Not
> sure yet whether that's an issue or not.  One (simple) solution is to
> change the semantics of persist() to be persistIfNotAlready()... that
> happens to be closer to JDO's semantics, and I don't think would break any
> other design assumptions in Isis.
> 
> Anyway, you should be good to go.
> 
> Cheers
> Dan
> 
> PS: looking at your code, you might want to check out the CoffeeBytes
> plugin along with the Eclipse templates, both on the Isis website [1].
> 
> 
> [1]http://incubator.apache.org/isis/ide-support.html
> 


-- 
ir. ing. Minto van der Sluis
Software innovator / renovator
Xup BV

Mobiel: +31 (0) 626 014541

Reply via email to