You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@roller.apache.org by Mitesh Meswani <Mi...@Sun.COM> on 2007/01/02 23:56:18 UTC
Files to checkin to roller trunk
Hi,
I am working to port Roller's backend code to use JPA/JDO (see
trunk/sandbox/jdobackend). I ran across some code that is not portable
across persistence strategies. Attached is a patch to fix that. The
patch is from trunk dir based on revision 491960
Following is a summary of changes:
1. src/org/apache/roller/pojos/FolderData.java,
src/org/apache/roller/pojos/WeblogCategoryData.java:
JPA assumes that relationships are managed by user code and not
persistence provider. If we have a one-to-many relationship, if the
"many side" is set to point to an instance, the "one side" also needs to
add it the collection. For example if we set a FolderData's "parent",
the parent should add it to its "childFolders" collection. FolderData
and WeblogCategoryData is modified to follow this convention.
2. tests/org/apache/roller/business/PingsTest.java
The test calls AutpoingManager#removeAutoPings(Collection) passing it a
collection of unmanged instances. It is modified to remove manged
version instead. I have verified that when
AutpoingManager#removeAutoPings is called from roller
code(PingSetupAction#disableSelected()), the instances are managed
I have successfully run all tests against hibernate-derby with these
changes. Please review and check in.
Thanks,
Mitesh
Re: Changes to FolderData and WeblogCategoryData
Posted by Craig L Russell <Cr...@Sun.COM>.
I've applied the changes and committed them.
Craig
svn commit -m "Roll back managed relationship changes from revision
492013" src/org/apache/roller/pojos/WeblogCategoryData.java src/org/
apache/roller/pojos/FolderData.java
Sending src/org/apache/roller/pojos/FolderData.java
Sending src/org/apache/roller/pojos/WeblogCategoryData.java
Transmitting file data ..
Committed revision 494698.
On Jan 9, 2007, at 7:03 PM, Mitesh Meswani wrote:
> 492013
Craig Russell
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:Craig.Russell@sun.com
P.S. A good JDO? O, Gasp!
Changes to FolderData and WeblogCategoryData
Posted by Mitesh Meswani <Mi...@Sun.COM>.
Revision 492013 (http://svn.apache.org/viewvc?view=rev&rev=492013)
modified these pojos to maintain both sides of relationships in the
constructor. Going through rest of roller code, it seems to be more
consistent to maintain these relationships from respective mangers. I am
proposing to rollback these changes. Attached is a patch that rollback
the changes to these pojos. Please note that Hibernate does not enforce
maintaining relationships from both sides hence no code in
Hibernate*ManagerImpl is changed.
I have successfully run all the business unit tests against
hibernate-derby in a clean workspace with these changes.
Thanks,
Mitesh
Mitesh Meswani wrote:
> Hi,
>
> I am working to port Roller's backend code to use JPA/JDO (see
> trunk/sandbox/jdobackend). I ran across some code that is not portable
> across persistence strategies. Attached is a patch to fix that. The
> patch is from trunk dir based on revision 491960
>
> Following is a summary of changes:
> 1. src/org/apache/roller/pojos/FolderData.java,
> src/org/apache/roller/pojos/WeblogCategoryData.java:
> JPA assumes that relationships are managed by user code and not
> persistence provider. If we have a one-to-many relationship, if the
> "many side" is set to point to an instance, the "one side" also needs
> to add it the collection. For example if we set a FolderData's
> "parent", the parent should add it to its "childFolders" collection.
> FolderData and WeblogCategoryData is modified to follow this convention.
>
> 2. tests/org/apache/roller/business/PingsTest.java
> The test calls AutpoingManager#removeAutoPings(Collection) passing it
> a collection of unmanged instances. It is modified to remove manged
> version instead. I have verified that when
> AutpoingManager#removeAutoPings is called from roller
> code(PingSetupAction#disableSelected()), the instances are managed
>
> I have successfully run all tests against hibernate-derby with these
> changes. Please review and check in.
>
> Thanks,
> Mitesh
>
>
>
>
> ------------------------------------------------------------------------
>
> Index: src/org/apache/roller/pojos/FolderData.java
> ===================================================================
> --- src/org/apache/roller/pojos/FolderData.java (revision 491943)
> +++ src/org/apache/roller/pojos/FolderData.java (working copy)
> @@ -84,6 +84,15 @@
> } else {
> this.path = parent.getPath() + "/" + name;
> }
> +
> + this.parentFolder = parent;
> + // Relationship needs to be maintained from both sides
> + if(parent != null) {
> + // Following triggers this.hascode(). Which is calculated based on this.path
> + // It needs to happen after this.path is initialized
> + parent.childFolders.add(this);
> + }
> +
> }
>
>
> Index: src/org/apache/roller/pojos/WeblogCategoryData.java
> ===================================================================
> --- src/org/apache/roller/pojos/WeblogCategoryData.java (revision 491943)
> +++ src/org/apache/roller/pojos/WeblogCategoryData.java (working copy)
> @@ -71,8 +71,7 @@
> this.image = image;
>
> this.website = website;
> - this.parentCategory = parent;
> -
> +
> // calculate path
> if(parent == null) {
> this.path = "/";
> @@ -81,6 +80,15 @@
> } else {
> this.path = parent.getPath() + "/" + name;
> }
> +
> + this.parentCategory = parent;
> + // Relationship needs to be maintained from both sides
> + if(parent != null) {
> + // Following triggers this.hascode(). Which is calculated based on this.path
> + // It needs to happen after this.path is initialized
> + parent.childCategories.add(this);
> + }
> +
> }
>
>
> Index: tests/org/apache/roller/business/PingsTest.java
> ===================================================================
> --- tests/org/apache/roller/business/PingsTest.java (revision 491943)
> +++ tests/org/apache/roller/business/PingsTest.java (working copy)
> @@ -314,7 +314,9 @@
>
> // remove a collection
> List autoPings = new ArrayList();
> + autoPing2 = mgr.getAutoPing(autoPing2.getId()); //Get managed version of autoPing2
> autoPings.add(autoPing2);
> + autoPing3 = mgr.getAutoPing(autoPing3.getId()); //Get managed version of autoPing2
> autoPings.add(autoPing3);
> mgr.removeAutoPings(autoPings);
> TestUtils.endSession(true);
>
Re: Files to checkin to roller trunk
Posted by Craig L Russell <Cr...@Sun.COM>.
I've checked in these changes.
Craig
svn commit -m "Manage relationships on both sides" src tests
Sending src/org/apache/roller/pojos/FolderData.java
Sending src/org/apache/roller/pojos/WeblogCategoryData.java
Sending tests/org/apache/roller/business/PingsTest.java
Transmitting file data ...
Committed revision 492013.
On Jan 2, 2007, at 2:56 PM, Mitesh Meswani wrote:
> Hi,
>
> I am working to port Roller's backend code to use JPA/JDO (see
> trunk/sandbox/jdobackend). I ran across some code that is not
> portable across persistence strategies. Attached is a patch to fix
> that. The patch is from trunk dir based on revision 491960
>
> Following is a summary of changes:
> 1. src/org/apache/roller/pojos/FolderData.java, src/org/apache/
> roller/pojos/WeblogCategoryData.java:
> JPA assumes that relationships are managed by user code and not
> persistence provider. If we have a one-to-many relationship, if the
> "many side" is set to point to an instance, the "one side" also
> needs to add it the collection. For example if we set a
> FolderData's "parent", the parent should add it to its
> "childFolders" collection. FolderData and WeblogCategoryData is
> modified to follow this convention.
>
> 2. tests/org/apache/roller/business/PingsTest.java
> The test calls AutpoingManager#removeAutoPings(Collection) passing
> it a collection of unmanged instances. It is modified to remove
> manged version instead. I have verified that when
> AutpoingManager#removeAutoPings is called from roller code
> (PingSetupAction#disableSelected()), the instances are managed
>
> I have successfully run all tests against hibernate-derby with
> these changes. Please review and check in.
>
> Thanks,
> Mitesh
>
>
>
>
> Index: src/org/apache/roller/pojos/FolderData.java
> ===================================================================
> --- src/org/apache/roller/pojos/FolderData.java (revision 491943)
> +++ src/org/apache/roller/pojos/FolderData.java (working copy)
> @@ -84,6 +84,15 @@
> } else {
> this.path = parent.getPath() + "/" + name;
> }
> +
> + this.parentFolder = parent;
> + // Relationship needs to be maintained from both sides
> + if(parent != null) {
> + // Following triggers this.hascode(). Which is
> calculated based on this.path
> + // It needs to happen after this.path is initialized
> + parent.childFolders.add(this);
> + }
> +
> }
>
>
> Index: src/org/apache/roller/pojos/WeblogCategoryData.java
> ===================================================================
> --- src/org/apache/roller/pojos/WeblogCategoryData.java (revision
> 491943)
> +++ src/org/apache/roller/pojos/WeblogCategoryData.java (working copy)
> @@ -71,8 +71,7 @@
> this.image = image;
>
> this.website = website;
> - this.parentCategory = parent;
> -
> +
> // calculate path
> if(parent == null) {
> this.path = "/";
> @@ -81,6 +80,15 @@
> } else {
> this.path = parent.getPath() + "/" + name;
> }
> +
> + this.parentCategory = parent;
> + // Relationship needs to be maintained from both sides
> + if(parent != null) {
> + // Following triggers this.hascode(). Which is
> calculated based on this.path
> + // It needs to happen after this.path is initialized
> + parent.childCategories.add(this);
> + }
> +
> }
>
>
> Index: tests/org/apache/roller/business/PingsTest.java
> ===================================================================
> --- tests/org/apache/roller/business/PingsTest.java (revision 491943)
> +++ tests/org/apache/roller/business/PingsTest.java (working copy)
> @@ -314,7 +314,9 @@
>
> // remove a collection
> List autoPings = new ArrayList();
> + autoPing2 = mgr.getAutoPing(autoPing2.getId()); //Get
> managed version of autoPing2
> autoPings.add(autoPing2);
> + autoPing3 = mgr.getAutoPing(autoPing3.getId()); //Get
> managed version of autoPing2
> autoPings.add(autoPing3);
> mgr.removeAutoPings(autoPings);
> TestUtils.endSession(true);
Craig Russell
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:Craig.Russell@sun.com
P.S. A good JDO? O, Gasp!