hongluu / krank

Automatically exported from code.google.com/p/krank
0 stars 0 forks source link

DetailController.doDelete() should dao.delete() not dao.merge() #33

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
While it is appropriate to update() the parent when forceUpdate and
dao==null, it is not appropriate to merge() when dao != null.

I'm having great success using a detail controller with only a
loosely-coupled parent/children relationship -- where children are not in
the object graph with the parent, but are associated in the database with a
foreign-key relationship all the same.

I've sub-classed RelationshipManager to redefine what it means when such a
child is added to such a parent.  All crud operations happen as expected,
except for delete -- the child entity is not getting deleted with the code
as is.  In fact, when I violate abstraction and call delete() from my
removeFromParent(), doDelete()'s merge() adds it back!  When I change
"dao.merge(entity)" to "dao.delete(entity)", all crud operations work.

BTW, shouldn't RelationshipManager be an interface, rather than a class?

> What version of the product are you using? On what operating system?

 crank-crud-1.0RC2-SNAPSHOT
 Java(TM) SE Runtime Environment (build 1.6.0_06-b02)
 Linux ... 2.6.24-19-generic #1 SMP ... i686 GNU/Linux
 cat /etc/issue => Ubuntu 8.04.1

> Please provide any additional information below.

I'm still amazed at how complex and fun Crank is.  I'm not exactly sure if
it has saved me time in developing my first JPA/JSF project, but I've
learned so much.  Thanks.

Original issue reported on code.google.com by james.ju...@gmail.com on 15 Jul 2008 at 6:00

Attachments: