Allen Gilliland wrote:
Craig L Russell wrote:
Hi Mitesh,
...we can generate and assign a UUID in constructor of the pojos. We
can use UUID generator based on JavaSE 5 or use one bundled with
apache commons
(http://jakarta.apache.org/commons/sandbox/id/apidocs/org/apache/commons/id/uuid/UUID.html)
+1
Until all persistence providers support UUID generation as part of
their feature set, I think it makes sense for Roller to generate the
id and give it to the persistence provider. 100% portable and using
the Apache code makes it pre-1.5 compatible.
I am fine with generating our own UUIDs, assuming that there is no way
for upgrading users to run into problems, but I'm not sure about using
them in the equals() and hashCode() implementations.
WebsiteData w1 = new WebsiteData(handle="foo");
WebsiteData w2 = new WebsiteData(handle="foo");
w1.equals(w2);
If ids are generated and used for equals() and hashCode() instead of
real business keys like we are trying to do now then the statement
above would be false, which is wrong, right?
Yes it is wrong. But, I think it as less evil than than getting data
corruption because one of the attributes used in equals() or hashcode()
calculation is mutated after an object is put in cache.
BTW, just as proof of concept, I modified the pojos as attached. Atleast
all the tests are passing with these changes. (please note that I am not
proposing to checkin these changes :) )
Thanks,
Mitesh
-- Allen
Craig
On Jan 24, 2007, at 2:50 PM, Mitesh Meswani wrote:
Allen Gilliland wrote:
I agree, and in general any object which is associated with a
specific weblog should probably be using the website in its
equals() and hashCode() methods. So maybe the what really needs to
happen is to revert revision 499419 which removes those comparisons
from the Folder and Category objects.
Revision 499419 is a workaround for a toplink issue. From the
comments in previous version of code ("NOTE: currently we are
implementing equals only using the path of the folder. technically
the business key should be for both the weblog & path, but we don't
expect to be comparing folders from 2 different weblogs so this
should be fine"), I think the workaround should be ok for now.
While we are on issue of equals() and hashcode() - Currently the
impls of this methods use couple of fields that are mutable (e.g
FolderData uses path which will change if a folder is moved or
renamed). I think it is not a good idea to have any mutable field as
part of the calculation. If the field is mutated after the pojo is
placed in a collection (almost all the persistence providers use
them for caching) we might get into issues that are hard to debug.
I think we require current form of equals() and hashcode() that uses
couple of fields instead of pk of the object for equality because we
are using generated ids. I am proposing that we switch to user
supplied ids. Instead of hibernate generating a UUID and assigning
it at insert time, we can generate and assign a UUID in constructor
of the pojos. We can use UUID generator based on JavaSE 5 or use one
bundled with apache commons
(http://jakarta.apache.org/commons/sandbox/id/apidocs/org/apache/commons/id/uuid/UUID.html)
What do others think?
Thanks,
Mitesh
-- Allen
Mitesh Meswani wrote:
Hi Dave,
I don't think this is a workaround. At least during the test I
came across instances of RefererData that belonged to different
website but where refererUrl was equal and weblogEntry was null.
Is that not a probable scenario?
Regards,
Mitesh
[EMAIL PROTECTED] wrote:
Author: snoopdave
Date: Wed Jan 24 06:36:15 2007
New Revision: 499420
URL: http://svn.apache.org/viewvc?view=rev&rev=499420
Log:
Add website to equals() and hashCode(), which is redundant but
allows us to work around a JPA issue.
Modified:
incubator/roller/trunk/src/org/apache/roller/pojos/RefererData.java
Modified:
incubator/roller/trunk/src/org/apache/roller/pojos/RefererData.java
URL:
http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/pojos/RefererData.java?view=diff&rev=499420&r1=499419&r2=499420
==============================================================================
---
incubator/roller/trunk/src/org/apache/roller/pojos/RefererData.java
(original)
+++
incubator/roller/trunk/src/org/apache/roller/pojos/RefererData.java
Wed Jan 24 06:36:15 2007
@@ -438,6 +438,7 @@
return new EqualsBuilder()
.append(getRefererUrl(),
o.getRefererUrl()) .append(getWeblogEntry(),
o.getWeblogEntry()) +
.append(getWebsite(),o.getWebsite())
.isEquals();
}
@@ -445,6 +446,7 @@
return new HashCodeBuilder()
.append(getRefererUrl())
.append(getWeblogEntry())
+ .append(getWebsite())
.toHashCode();
}
Craig Russell
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:[EMAIL PROTECTED]
P.S. A good JDO? O, Gasp!
Index: src/org/apache/roller/pojos/BookmarkData.java
===================================================================
--- src/org/apache/roller/pojos/BookmarkData.java (revision 499603)
+++ src/org/apache/roller/pojos/BookmarkData.java (working copy)
@@ -46,7 +46,7 @@
private FolderData folder;
- private String id = null;
+ private String id = UUIDGenerator.generateUUID();
private String name;
private String description;
private String url;
@@ -97,8 +97,8 @@
*
* @ejb:persistent-field
*
- * @hibernate.id column="id"
- * generator-class="uuid.hex" unsaved-value="null"
+ * @hibernate.id column="id" generator-class="assigned"
+ *
*/
public String getId()
{
@@ -289,15 +289,13 @@
if (other instanceof BookmarkData != true) return false;
BookmarkData o = (BookmarkData)other;
return new EqualsBuilder()
- .append(getName(), o.getName())
- .append(getFolder(), o.getFolder())
+ .append(getId(), o.getId())
.isEquals();
}
public int hashCode() {
return new HashCodeBuilder()
- .append(getName())
- .append(getFolder())
+ .append(getId())
.toHashCode();
}
Index: src/org/apache/roller/pojos/FolderData.java
===================================================================
--- src/org/apache/roller/pojos/FolderData.java (revision 499603)
+++ src/org/apache/roller/pojos/FolderData.java (working copy)
@@ -50,7 +50,7 @@
public static final long serialVersionUID = -6272468884763861944L;
// attributes
- private String id = null;
+ private String id = UUIDGenerator.generateUUID();
private String name = null;
private String description = null;
private String path = null;
@@ -114,8 +114,7 @@
if (other instanceof FolderData) {
FolderData o = (FolderData) other;
return new EqualsBuilder()
- .append(getPath(), o.getPath())
- //.append(getWebsite(), o.getWebsite())
+ .append(getId(), o.getId())
.isEquals();
}
@@ -128,8 +127,7 @@
*/
public int hashCode() {
return new HashCodeBuilder()
- .append(getPath())
- //.append(getWebsite())
+ .append(getId())
.toHashCode();
}
@@ -146,8 +144,8 @@
*
* @roller.wrapPojoMethod type="simple"
*
- * @hibernate.id column="id"
- * generator-class="uuid.hex" unsaved-value="null"
+ * @hibernate.id column="id" generator-class="assigned"
+ *
*/
public String getId() {
return this.id;
Index: src/org/apache/roller/pojos/UserData.java
===================================================================
--- src/org/apache/roller/pojos/UserData.java (revision 499603)
+++ src/org/apache/roller/pojos/UserData.java (working copy)
@@ -56,7 +56,7 @@
static final long serialVersionUID = -6354583200913127874L;
- private String id;
+ private String id = UUIDGenerator.generateUUID();
private String userName;
private String password;
private String fullName;
@@ -78,7 +78,7 @@
String locale, String timeZone,
Date dateCreated,
Boolean isEnabled) {
- this.id = id;
+ //this.id = id; // TODO: Check. two invokers of this ctor pass n/a as
id!!!!
this.userName = userName;
this.password = password;
this.fullName = fullName;
@@ -124,8 +124,8 @@
*
* @struts.validator type="required" msgkey="errors.required"
* @ejb:persistent-field
- * @hibernate.id column="id"
- * generator-class="uuid.hex" unsaved-value="null"
+ * @hibernate.id column="id" generator-class="assigned"
+ *
*/
public String getId() {
return this.id;
@@ -353,11 +353,13 @@
if (other == this) return true;
if (other instanceof UserData != true) return false;
UserData o = (UserData)other;
- return new EqualsBuilder().append(getUserName(),
o.getUserName()).isEquals();
+ return new EqualsBuilder()
+ .append(getId(), o.getId())
+ .isEquals();
}
public int hashCode() {
- return new HashCodeBuilder().append(getUserName()).toHashCode();
+ return new HashCodeBuilder().append(getId()).toHashCode();
}
}
Index: src/org/apache/roller/pojos/PingCategoryRestrictionData.java
===================================================================
--- src/org/apache/roller/pojos/PingCategoryRestrictionData.java
(revision 499603)
+++ src/org/apache/roller/pojos/PingCategoryRestrictionData.java
(working copy)
@@ -36,7 +36,7 @@
* @hibernate.cache usage="read-write"
*/
public class PingCategoryRestrictionData implements Serializable {
- private String id;
+ private String id = UUIDGenerator.generateUUID();
private AutoPingData autoPing;
private WeblogCategoryData weblogCategory;
@@ -56,7 +56,7 @@
* @param weblogCategory weblog category to which this auto ping
configuration is restricted
*/
public PingCategoryRestrictionData(String id, AutoPingData autoPing,
WeblogCategoryData weblogCategory) {
- this.id = id;
+ // this.id = id; // TODO this ctor is not used should be removed
this.autoPing = autoPing;
this.weblogCategory = weblogCategory;
}
@@ -75,7 +75,7 @@
*
* @return the unique id of this object. -- struts.validator
type="required" msgkey="errors.required"
* @ejb:persistent-field
- * @hibernate.id column="id" generator-class="uuid.hex"
unsaved-value="null"
+ * @hibernate.id column="id" generator-class="assigned"
*/
public String getId() {
return id;
@@ -146,15 +146,13 @@
if (other instanceof PingCategoryRestrictionData != true) return false;
PingCategoryRestrictionData o = (PingCategoryRestrictionData)other;
return new EqualsBuilder()
- .append(getWeblogCategory(), o.getWeblogCategory())
- .append(getAutoping(), o.getAutoping())
+ .append(getId(), o.getId())
.isEquals();
}
public int hashCode() {
return new HashCodeBuilder()
- .append(getWeblogCategory())
- .append(getAutoping())
+ .append(getId())
.toHashCode();
}
}
\ No newline at end of file
Index: src/org/apache/roller/pojos/WeblogTemplate.java
===================================================================
--- src/org/apache/roller/pojos/WeblogTemplate.java (revision 499603)
+++ src/org/apache/roller/pojos/WeblogTemplate.java (working copy)
@@ -49,7 +49,7 @@
private static Log log = LogFactory.getLog(WeblogTemplate.class);
private static Set requiredTemplates = null;
- private String id = null;
+ private String id = UUIDGenerator.generateUUID();
private String name = null;
private String description = null;
private String link = null;
@@ -85,7 +85,7 @@
boolean hid,
boolean navbar,
String decorator) {
- this.id = id;
+ // this.id = id; //TODO check one caller of this method passes
templates/weblog/popupcomments.vm as id !!!
this.weblog = website;
this.name = name;
this.description = description;
@@ -118,8 +118,8 @@
/**
* @ejb:persistent-field
- * @hibernate.id column="id"
- * generator-class="uuid.hex" unsaved-value="null"
+ * @hibernate.id column="id" generator-class="assigned"
+ *
*/
public java.lang.String getId() {
return this.id;
@@ -311,15 +311,13 @@
if (other instanceof WeblogTemplate != true) return false;
WeblogTemplate o = (WeblogTemplate)other;
return new EqualsBuilder()
- .append(name, o.getName())
- .append(getWebsite(), o.getWebsite())
+ .append(getId(), o.getId())
.isEquals();
}
public int hashCode() {
return new HashCodeBuilder()
- .append(getName())
- .append(getWebsite())
+ .append(getId())
.toHashCode();
}
Index: src/org/apache/roller/pojos/EntryAttributeData.java
===================================================================
--- src/org/apache/roller/pojos/EntryAttributeData.java (revision 499603)
+++ src/org/apache/roller/pojos/EntryAttributeData.java (working copy)
@@ -28,7 +28,7 @@
*/
public class EntryAttributeData implements java.lang.Comparable
{
- private String id;
+ private String id = UUIDGenerator.generateUUID();
private WeblogEntryData entry;
private String name;
private String value;
@@ -43,7 +43,7 @@
String name,
String value)
{
- this.id = id;
+ //this.id = id; // TODO: No one calls this ctor should be removed
this.entry = entry;
this.name = name;
this.value = value;
@@ -57,8 +57,8 @@
/**
* @roller.wrapPojoMethod type="simple"
* @ejb:persistent-field
- * @hibernate.id column="id"
- * generator-class="uuid.hex" unsaved-value="null"
+ * @hibernate.id column="id" generator-class="assigned"
+ *
*/
public java.lang.String getId()
{
@@ -145,15 +145,13 @@
if (other instanceof EntryAttributeData != true) return false;
EntryAttributeData o = (EntryAttributeData)other;
return new EqualsBuilder()
- .append(getName(), o.getName())
- .append(getEntry(), o.getEntry())
+ .append(getId(), o.getId())
.isEquals();
}
public int hashCode() {
return new HashCodeBuilder()
- .append(getName())
- .append(getEntry())
+ .append(getId())
.toHashCode();
}
}
Index: src/org/apache/roller/pojos/RefererData.java
===================================================================
--- src/org/apache/roller/pojos/RefererData.java (revision 499603)
+++ src/org/apache/roller/pojos/RefererData.java (working copy)
@@ -39,7 +39,7 @@
implements java.io.Serializable
{
static final long serialVersionUID = -1817992900602131316L;
- private java.lang.String id = null;
+ private java.lang.String id = UUIDGenerator.generateUUID();
private org.apache.roller.pojos.WebsiteData website = null;
private org.apache.roller.pojos.WeblogEntryData weblogEntry = null;
private java.lang.String dateString = null;
@@ -67,7 +67,7 @@
java.lang.Boolean duplicate, java.lang.Integer dayHits,
java.lang.Integer totalHits)
{
- this.id = id;
+ // this.id = id; // TODO this field should not be passed into ctor
this.website = website;
this.weblogEntry = weblogEntry;
this.dateString = dateString;
@@ -93,8 +93,8 @@
* Unique ID and primary key of this Referer.
*
* @roller.wrapPojoMethod type="simple"
- * @hibernate.id column="id"
- * generator-class="uuid.hex" unsaved-value="null"
+ * @hibernate.id column="id" generator-class="assigned"
+ *
*/
public java.lang.String getId()
{
@@ -436,17 +436,13 @@
if (other instanceof RefererData != true) return false;
RefererData o = (RefererData)other;
return new EqualsBuilder()
- .append(getRefererUrl(), o.getRefererUrl())
- .append(getWeblogEntry(), o.getWeblogEntry())
- .append(getWebsite(),o.getWebsite())
+ .append(getId(), o.getId())
.isEquals();
}
public int hashCode() {
return new HashCodeBuilder()
- .append(getRefererUrl())
- .append(getWeblogEntry())
- .append(getWebsite())
+ .append(getId())
.toHashCode();
}
Index: src/org/apache/roller/pojos/HitCountData.java
===================================================================
--- src/org/apache/roller/pojos/HitCountData.java (revision 499603)
+++ src/org/apache/roller/pojos/HitCountData.java (working copy)
@@ -21,8 +21,8 @@
import java.io.Serializable;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang.builder.EqualsBuilder;
-
/**
* Represents hit count data for a weblog.
*
@@ -32,7 +32,7 @@
*/
public class HitCountData implements Serializable {
- private String id = null;
+ private String id = UUIDGenerator.generateUUID();
private WebsiteData weblog = null;
private int dailyHits = 0;
@@ -56,25 +56,29 @@
//------------------------------------------------------------------------
public boolean equals(Object other) {
-
- if(this == other) return true;
- if( !(other instanceof HitCountData) ) return false;
-
- // our natural key, or business key, is our weblog
- final HitCountData that = (HitCountData) other;
- return this.getWeblog().equals(that.getWeblog());
+ if (other == null) return false;
+
+ if (other instanceof HitCountData) {
+ HitCountData o = (HitCountData) other;
+ return new EqualsBuilder()
+ .append(getId(), o.getId())
+ .isEquals();
+ }
+
+ return false;
+
}
public int hashCode() {
return new HashCodeBuilder()
- .append(getWeblog())
+ .append(getId())
.toHashCode();
}
/**
* @ejb:persistent-field
- * @hibernate.id column="id" generator-class="uuid.hex"
unsaved-value="null"
+ * @hibernate.id column="id" generator-class="assigned"
*/
public String getId() {
return id;
Index: src/org/apache/roller/pojos/RoleData.java
===================================================================
--- src/org/apache/roller/pojos/RoleData.java (revision 499603)
+++ src/org/apache/roller/pojos/RoleData.java (working copy)
@@ -37,7 +37,7 @@
{
static final long serialVersionUID = -4254083071697970972L;
- private java.lang.String id;
+ private java.lang.String id = UUIDGenerator.generateUUID();
private java.lang.String userName;
private UserData user;
private java.lang.String role;
@@ -48,7 +48,7 @@
public RoleData(String id, UserData user, String role)
{
- this.id = id;
+ //this.id = id; // TODO: this parameter should be removed from
constructor
this.userName = user.getUserName();
this.user = user;
this.role = role;
@@ -62,8 +62,8 @@
/**
* @ejb:pk-field
* @ejb:persistent-field
- * @hibernate.id column="id"
- * generator-class="uuid.hex" unsaved-value="null"
+ * @hibernate.id column="id" generator-class="assigned"
+ *
*/
public java.lang.String getId()
{
@@ -131,13 +131,12 @@
if (other instanceof RoleData != true) return false;
RoleData o = (RoleData)other;
return new EqualsBuilder()
- .append(getRole(), o.getRole())
- .append(getUserName(), o.getUserName())
+ .append(getId(), o.getId())
.isEquals();
}
public int hashCode() {
- return new
HashCodeBuilder().append(getUserName()).append(getRole()).toHashCode();
+ return new HashCodeBuilder().append(getId()).toHashCode();
}
/**
Index: src/org/apache/roller/pojos/WeblogEntryTagAggregateData.java
===================================================================
--- src/org/apache/roller/pojos/WeblogEntryTagAggregateData.java
(revision 499603)
+++ src/org/apache/roller/pojos/WeblogEntryTagAggregateData.java
(working copy)
@@ -38,7 +38,7 @@
implements java.io.Serializable
{
private static final long serialVersionUID = -4343500268898106982L;
- private java.lang.String id = null;
+ private java.lang.String id = UUIDGenerator.generateUUID();
private java.lang.String name = null;
private WebsiteData website = null;
private Timestamp lastUsed = null;
@@ -52,7 +52,7 @@
WebsiteData website,
java.lang.String name, int total)
{
- this.id = id;
+ //this.id = id; // TODO: this parameter should be removed from
constructor
this.website = website;
this.name = name;
this.total = total;
@@ -68,7 +68,7 @@
/**
* Unique ID and primary key of this Referer.
*
- * @hibernate.id column="id" generator-class="uuid.hex"
unsaved-value="null"
+ * @hibernate.id column="id" generator-class="assigned"
*/
public java.lang.String getId()
{
@@ -154,15 +154,13 @@
if (other instanceof WeblogEntryTagAggregateData != true) return false;
WeblogEntryTagAggregateData o = (WeblogEntryTagAggregateData)other;
return new EqualsBuilder()
- .append(getName(), o.getName())
- .append(this.getWeblog(), o.getWeblog())
+ .append(getId(), o.getId())
.isEquals();
}
public int hashCode() {
return new HashCodeBuilder()
- .append(getName())
- .append(getWeblog())
+ .append(getId())
.toHashCode();
}
Index: src/org/apache/roller/pojos/TaskLockData.java
===================================================================
--- src/org/apache/roller/pojos/TaskLockData.java (revision 499603)
+++ src/org/apache/roller/pojos/TaskLockData.java (working copy)
@@ -33,7 +33,7 @@
*/
public class TaskLockData implements Serializable {
- private String id = null;
+ private String id = UUIDGenerator.generateUUID();
private String name = null;
private boolean locked = false;
private Date timeAquired = null;
@@ -106,17 +106,17 @@
// our natural key, or business key, is our name
final TaskLockData that = (TaskLockData) other;
- return this.getName().equals(that.getName());
+ return this.getId().equals(that.getId());
}
public int hashCode() {
// our natrual key, or business key, is our name
- return this.getName().hashCode();
+ return this.getId().hashCode();
}
/**
* @ejb:persistent-field
- * @hibernate.id column="id" generator-class="uuid.hex"
unsaved-value="null"
+ * @hibernate.id column="id" generator-class="assigned"
*/
public String getId() {
return id;
Index: src/org/apache/roller/pojos/PermissionsData.java
===================================================================
--- src/org/apache/roller/pojos/PermissionsData.java (revision 499603)
+++ src/org/apache/roller/pojos/PermissionsData.java (working copy)
@@ -32,7 +32,7 @@
*/
public class PermissionsData
{
- private String id = null;
+ private String id = UUIDGenerator.generateUUID();
private WebsiteData website = null;
private UserData user = null;
private boolean pending = true;
@@ -55,8 +55,8 @@
}
/**
* @ejb:persistent-field
- * @hibernate.id column="id"
- * generator-class="uuid.hex" unsaved-value="null"
+ * @hibernate.id column="id" generator-class="assigned"
+ *
*/
public String getId()
{
@@ -132,15 +132,13 @@
if (other instanceof PermissionsData != true) return false;
PermissionsData o = (PermissionsData)other;
return new EqualsBuilder()
- .append(user, o.user)
- .append(website, o.website)
+ .append(getId(), o.getId())
.isEquals();
}
public int hashCode() {
return new HashCodeBuilder()
- .append(user)
- .append(website)
+ .append(getId())
.toHashCode();
}
Index: src/org/apache/roller/pojos/WeblogCategoryData.java
===================================================================
--- src/org/apache/roller/pojos/WeblogCategoryData.java (revision 499603)
+++ src/org/apache/roller/pojos/WeblogCategoryData.java (working copy)
@@ -45,7 +45,7 @@
public static final long serialVersionUID = 1435782148712018954L;
// attributes
- private String id = null;
+ private String id = UUIDGenerator.generateUUID();
private String name = null;
private String description = null;
private String image = null;
@@ -118,17 +118,15 @@
if (other instanceof WeblogCategoryData) {
WeblogCategoryData o = (WeblogCategoryData)other;
return new EqualsBuilder()
- .append(getPath(), o.getPath())
- //.append(getWebsite(), o.getWebsite())
+ .append(getId(), o.getId())
.isEquals();
- }
+ }
return false;
}
public int hashCode() {
return new HashCodeBuilder()
- .append(getPath())
- //.append(getWebsite())
+ .append(getId())
.toHashCode();
}
@@ -138,8 +136,8 @@
*
* @roller.wrapPojoMethod type="simple"
*
- * @hibernate.id column="id"
- * generator-class="uuid.hex" unsaved-value="null"
+ * @hibernate.id column="id" generator-class="assigned"
+ *
*/
public java.lang.String getId() {
return this.id;
Index: src/org/apache/roller/pojos/PingQueueEntryData.java
===================================================================
--- src/org/apache/roller/pojos/PingQueueEntryData.java (revision 499603)
+++ src/org/apache/roller/pojos/PingQueueEntryData.java (working copy)
@@ -35,7 +35,7 @@
* @hibernate.cache usage="read-write"
*/
public class PingQueueEntryData implements Serializable {
- private String id = null;
+ private String id = UUIDGenerator.generateUUID();
private Timestamp entryTime = null;
private PingTargetData pingTarget = null;
private WebsiteData website = null;
@@ -59,7 +59,7 @@
* @param attempts number of prior ping attempts
*/
public PingQueueEntryData(String id, Timestamp entryTime, PingTargetData
pingTarget, WebsiteData website, int attempts) {
- this.id = id;
+ // this.id = id; // TODO: this parameter should be removed from
constructor
this.entryTime = entryTime;
this.pingTarget = pingTarget;
this.website = website;
@@ -82,7 +82,7 @@
*
* @return the unique id of this object.
* @ejb:persistent-field
- * @hibernate.id column="id" generator-class="uuid.hex"
unsaved-value="null"
+ * @hibernate.id column="id" generator-class="assigned"
*/
public String getId() {
return id;
@@ -204,15 +204,13 @@
if (other instanceof PingQueueEntryData != true) return false;
PingQueueEntryData o = (PingQueueEntryData)other;
return new EqualsBuilder()
- .append(getEntryTime(), o.getEntryTime())
- .append(getWebsite(), o.getWebsite())
+ .append(getId(), o.getId())
.isEquals();
}
public int hashCode() {
return new HashCodeBuilder()
- .append(getEntryTime())
- .append(getWebsite())
+ .append(getId())
.toHashCode();
}
}
Index: src/org/apache/roller/pojos/RollerConfigData.java
===================================================================
--- src/org/apache/roller/pojos/RollerConfigData.java (revision 499603)
+++ src/org/apache/roller/pojos/RollerConfigData.java (working copy)
@@ -45,7 +45,7 @@
{
static final long serialVersionUID = -6354583200913127875L;
- protected java.lang.String id = null;
+ protected java.lang.String id = UUIDGenerator.generateUUID();
/**
* Roller database version.
@@ -201,8 +201,8 @@
*
* @struts.validator type="required" msgkey="errors.required"
* @ejb:persistent-field
- * @hibernate.id column="id"
- * generator-class="uuid.hex" unsaved-value="null"
+ * @hibernate.id column="id" generator-class="assigned"
+ *
*/
public String getId() {
return this.id;
Index: src/org/apache/roller/pojos/AutoPingData.java
===================================================================
--- src/org/apache/roller/pojos/AutoPingData.java (revision 499603)
+++ src/org/apache/roller/pojos/AutoPingData.java (working copy)
@@ -35,7 +35,7 @@
* @hibernate.cache usage="read-write"
*/
public class AutoPingData implements Serializable {
- private String id = null;
+ private String id = UUIDGenerator.generateUUID();
private PingTargetData pingTarget = null;
private WebsiteData website = null;
@@ -55,7 +55,7 @@
* @param website website to which this configuration applies
*/
public AutoPingData(String id, PingTargetData pingtarget, WebsiteData
website) {
- this.id = id;
+// this.id = id; // TODO: this parameter should be removed from
constructor
this.website = website;
this.pingTarget = pingtarget;
}
@@ -74,7 +74,7 @@
*
* @return the unique id of this object. -- struts.validator
type="required" msgkey="errors.required"
* @ejb:persistent-field
- * @hibernate.id column="id" generator-class="uuid.hex"
unsaved-value="null"
+ * @hibernate.id column="id" generator-class="assigned"
*/
public String getId() {
return id;
@@ -148,8 +148,6 @@
AutoPingData o = (AutoPingData)other;
return new EqualsBuilder()
.append(getId(), o.getId())
- .append(getPingTarget(), o.getPingTarget())
- .append(getWebsite(), o.getWebsite())
.isEquals();
}
Index: src/org/apache/roller/pojos/WeblogEntryTagData.java
===================================================================
--- src/org/apache/roller/pojos/WeblogEntryTagData.java (revision 499603)
+++ src/org/apache/roller/pojos/WeblogEntryTagData.java (working copy)
@@ -39,7 +39,7 @@
implements java.io.Serializable
{
private static final long serialVersionUID = -2602052289337573384L;
- private java.lang.String id = null;
+ private java.lang.String id = UUIDGenerator.generateUUID();
private WebsiteData website = null;
private WeblogEntryData weblogEntry = null;
private UserData user = null;
@@ -50,19 +50,19 @@
{
}
- public WeblogEntryTagData(java.lang.String id,
- WebsiteData website,
- WeblogEntryData weblogEntry,
- UserData user, java.lang.String name,
- Timestamp time)
- {
- this.id = id;
- this.website = website;
- this.weblogEntry = weblogEntry;
- this.user = user;
- this.name = name;
- this.time = time;
- }
+// public WeblogEntryTagData(java.lang.String id,
+// WebsiteData website,
+// WeblogEntryData weblogEntry,
+// UserData user, java.lang.String name,
+// Timestamp time)
+// {
+// this.id = id;
+// this.website = website;
+// this.weblogEntry = weblogEntry;
+// this.user = user;
+// this.name = name;
+// this.time = time;
+// }
public WeblogEntryTagData(WeblogEntryTagData otherData)
{
@@ -75,7 +75,7 @@
* Unique ID and primary key of this Referer.
*
* @roller.wrapPojoMethod type="simple"
- * @hibernate.id column="id" generator-class="uuid.hex"
unsaved-value="null"
+ * @hibernate.id column="id" generator-class="assigned"
*/
public java.lang.String getId()
{
@@ -177,15 +177,13 @@
if (other instanceof WeblogEntryTagData != true) return false;
WeblogEntryTagData o = (WeblogEntryTagData)other;
return new EqualsBuilder()
- .append(getName(), o.getName())
- .append(getWeblogEntry(), o.getWeblogEntry())
+ .append(getId(), o.getId())
.isEquals();
}
public int hashCode() {
return new HashCodeBuilder()
- .append(getName())
- .append(getWeblogEntry())
+ .append(getId())
.toHashCode();
}
Index: src/org/apache/roller/pojos/ObjectAuditData.java
===================================================================
--- src/org/apache/roller/pojos/ObjectAuditData.java (revision 499603)
+++ src/org/apache/roller/pojos/ObjectAuditData.java (working copy)
@@ -31,7 +31,7 @@
*/
public class ObjectAuditData
{
- private String id; // primary key
+ private String id = UUIDGenerator.generateUUID(); // primary key
private String userId; // user that made change
private String objectId; // id of associated object, if any
private String objectClass; // name of associated object class (e.g.
WeblogEntryData)
@@ -40,8 +40,8 @@
/**
* @ejb:persistent-field
- * @hibernate.id column="id"
- * generator-class="uuid.hex" unsaved-value="null"
+ * @hibernate.id column="id" generator-class="assigned"
+ *
*/
public String getId()
{
Index: src/org/apache/roller/pojos/WeblogEntryData.java
===================================================================
--- src/org/apache/roller/pojos/WeblogEntryData.java (revision 499603)
+++ src/org/apache/roller/pojos/WeblogEntryData.java (working copy)
@@ -75,7 +75,7 @@
public static final String SCHEDULED = "SCHEDULED";
// Simple properies
- private String id = null;
+ private String id = UUIDGenerator.generateUUID();
private String title = null;
private String link = null;
private String summary = null;
@@ -111,30 +111,30 @@
public WeblogEntryData() {
}
- public WeblogEntryData(
- String id,
- WeblogCategoryData category,
- WebsiteData website,
- UserData creator,
- String title,
- String link,
- String text,
- String anchor,
- Timestamp pubTime,
- Timestamp updateTime,
- String status) {
- this.id = id;
- this.category = category;
- this.website = website;
- this.creator = creator;
- this.title = title;
- this.link = link;
- this.text = text;
- this.anchor = anchor;
- this.pubTime = pubTime;
- this.updateTime = updateTime;
- this.status = status;
- }
+// public WeblogEntryData(
+// String id,
+// WeblogCategoryData category,
+// WebsiteData website,
+// UserData creator,
+// String title,
+// String link,
+// String text,
+// String anchor,
+// Timestamp pubTime,
+// Timestamp updateTime,
+// String status) {
+// this.id = id;
+// this.category = category;
+// this.website = website;
+// this.creator = creator;
+// this.title = title;
+// this.link = link;
+// this.text = text;
+// this.anchor = anchor;
+// this.pubTime = pubTime;
+// this.updateTime = updateTime;
+// this.status = status;
+// }
public WeblogEntryData(WeblogEntryData otherData) {
this.setData(otherData);
@@ -176,15 +176,13 @@
if (other instanceof WeblogEntryData != true) return false;
WeblogEntryData o = (WeblogEntryData)other;
return new EqualsBuilder()
- .append(getAnchor(), o.getAnchor())
- .append(getWebsite(), o.getWebsite())
+ .append(getId(), o.getId())
.isEquals();
}
public int hashCode() {
return new HashCodeBuilder()
- .append(getAnchor())
- .append(getWebsite())
+ .append(getId())
.toHashCode();
}
@@ -193,7 +191,7 @@
/**
* @roller.wrapPojoMethod type="simple"
* @ejb:persistent-field
- * @hibernate.id column="id" generator-class="uuid.hex"
unsaved-value="null"
+ * @hibernate.id column="id" generator-class="assigned"
*/
public String getId() {
return this.id;
Index: src/org/apache/roller/pojos/CommentData.java
===================================================================
--- src/org/apache/roller/pojos/CommentData.java (revision 499603)
+++ src/org/apache/roller/pojos/CommentData.java (working copy)
@@ -43,7 +43,7 @@
public static final String SPAM = "SPAM";
public static final String PENDING = "PENDING";
- private String id = null;
+ private String id = UUIDGenerator.generateUUID();
private String name = null;
private String email = null;
@@ -83,8 +83,8 @@
* Database ID of comment
* @roller.wrapPojoMethod type="simple"
* @ejb:persistent-field
- * @hibernate.id column="id"
- * generator-class="uuid.hex" unsaved-value="null"
+ * @hibernate.id column="id" generator-class="assigned"
+ *
*/
public java.lang.String getId() {
return this.id;
@@ -362,17 +362,13 @@
if (other instanceof CommentData != true) return false;
CommentData o = (CommentData)other;
return new EqualsBuilder()
- .append(getName(), o.getName())
- .append(getPostTime(), o.getPostTime())
- .append(getWeblogEntry(), o.getWeblogEntry())
+ .append(getId(), o.getId())
.isEquals();
}
public int hashCode() {
return new HashCodeBuilder()
- .append(getName())
- .append(getPostTime())
- .append(getWeblogEntry())
+ .append(getId())
.toHashCode();
}
Index: src/org/apache/roller/pojos/WebsiteData.java
===================================================================
--- src/org/apache/roller/pojos/WebsiteData.java (revision 499603)
+++ src/org/apache/roller/pojos/WebsiteData.java (working copy)
@@ -67,7 +67,7 @@
private static Log log = LogFactory.getLog(WebsiteData.class);
// Simple properties
- private String id = null;
+ private String id = UUIDGenerator.generateUUID();
private String handle = null;
private String name = null;
private String description = null;
@@ -145,13 +145,13 @@
if (other instanceof WebsiteData != true) return false;
WebsiteData o = (WebsiteData)other;
return new EqualsBuilder()
- .append(getHandle(), o.getHandle())
+ .append(getId(), o.getId())
.isEquals();
}
public int hashCode() {
return new HashCodeBuilder()
- .append(getHandle())
+ .append(getId())
.toHashCode();
}
@@ -391,8 +391,8 @@
*
* @roller.wrapPojoMethod type="simple"
* @ejb:persistent-field
- * @hibernate.id column="id"
- * generator-class="uuid.hex" unsaved-value="null"
+ * @hibernate.id column="id" generator-class="assigned"
+ *
*/
public String getId() {
return this.id;
Index: src/org/apache/roller/pojos/PingTargetData.java
===================================================================
--- src/org/apache/roller/pojos/PingTargetData.java (revision 499603)
+++ src/org/apache/roller/pojos/PingTargetData.java (working copy)
@@ -44,7 +44,7 @@
public static final int CONDITION_FAILING = 1; // last use failed
after retrials
public static final int CONDITION_DISABLED = 2; // disabled by failure
policy after failures - editing resets
- private String id = null;
+ private String id = UUIDGenerator.generateUUID();
private String name = null;
private String pingUrl = null;
private WebsiteData website = null;
@@ -69,7 +69,7 @@
* @param website the website (on this server) for which this is a custom
ping target (may be null)
*/
public PingTargetData(String id, String name, String pingUrl, WebsiteData
website, boolean autoEnable) {
- this.id = id;
+ // this.id = id; // TODO: this parameter should be removed from
constructor
this.name = name;
this.pingUrl = pingUrl;
this.website = website;
@@ -100,7 +100,7 @@
* @return the unique id of this ping target.
* @struts.validator type="required" msgkey="errors.required"
* @ejb:persistent-field
- * @hibernate.id column="id" generator-class="uuid.hex"
unsaved-value="null"
+ * @hibernate.id column="id" generator-class="assigned"
*/
public java.lang.String getId() {
return this.id;
@@ -277,13 +277,13 @@
if (other instanceof PingTargetData != true) return false;
PingTargetData o = (PingTargetData)other;
return new EqualsBuilder()
- .append(getId(), o.getId())
+ .append(getId(), o.getId())
.isEquals();
}
public int hashCode() {
return new HashCodeBuilder()
- .append(id)
+ .append(getId())
.toHashCode();
}