public class TmcdbObject
extends java.lang.Object
PropertyChangeListener can subscribe to
changes in the internal object's properties and listen to them. Note though that this
feature is only possible when classes extending TmcdbObject fire property
changes on their property setters, which is the case of the code-generated classes.
equals() and
hashCode() methods should use the default java Object
implementations, or the equalsContent() and hashCodeContent()
ones. These new methods should be reimplemented by classes extending TmcdbObject,
using business logic, otherwise the methods declared in this class will be used,
which call to Object.equals(Object) and Object.hashCode() anyway.
In the case of code-generated classes, these methods are created, if it is the case,
with the columns present in the "GENERATED FROM" statement of the model. For further
details, refer to the grammar definition for the TMCDB models.
By default, the Object methods will be used. This can be changed by the user
at any time by calling setUseContentEqualsAndHashCode(boolean).
NOTE: Use this with care. This option is available for it eases life
to some programs, but it might lead to hard-to-recognize problems. Please refer to
http://www.artima.com/lejava/articles/equality.html and to the Set class
documentation for further details
| Modifier and Type | Field and Description |
|---|---|
protected java.beans.PropertyChangeSupport |
propertyChangeSupport |
protected static boolean |
USE_CONTENT_EQUALS_AND_HASHCODE_DEFAULT |
protected boolean |
useContentEqualsAndHashCode |
| Constructor and Description |
|---|
TmcdbObject() |
| Modifier and Type | Method and Description |
|---|---|
void |
addPropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener listener) |
boolean |
equals(java.lang.Object o) |
boolean |
equalsContent(java.lang.Object o) |
boolean |
getUseContentEqualsAndHashCode() |
int |
hashCode() |
int |
hashCodeContent() |
void |
removePropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener listener) |
void |
setUseContentEqualsAndHashCode(boolean u)
Deprecated.
Now that we have the static method
setUseContentEqualsAndHashCodeDefault(boolean),
it seems that there is no further use for this method, so that it should be removed after ACS 10.1. |
static void |
setUseContentEqualsAndHashCodeDefault(boolean uDefault)
Sets the default value for
useContentEqualsAndHashCode. |
protected java.beans.PropertyChangeSupport propertyChangeSupport
protected static boolean USE_CONTENT_EQUALS_AND_HASHCODE_DEFAULT
protected boolean useContentEqualsAndHashCode
public void addPropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener listener)
public void removePropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener listener)
public static void setUseContentEqualsAndHashCodeDefault(boolean uDefault)
useContentEqualsAndHashCode.
Applications such as the TmcdbExplorer, which prefer to use field data
for the equals and hash code behavior, should call this method before
creating any TmcdbObjects (once for every classloader scope, which may only be once in total).
Other applications such as rdbCDB, which prefer to use only in-memory object identity,
can either call this method or rely on the default of the default value that is false.
Note that the previous method setUseContentEqualsAndHashCode(boolean) (now deprecated)
was problematic because it could only be called after constructing a TmcdbObject,
when hibernate had already added it automatically to some of its collections,
and then the object identity was changed too late when calling that method.
If we are not satisfied with this static variable solution, we should continue the
discussion about using UUID.randomUUID()
(http://onjava.com/pub/a/onjava/2006/09/13/dont-let-hibernate-steal-your-identity.html)
for TmcdbObject identity, as Steve Harrington suggested in June 2011.
uDefault - public boolean getUseContentEqualsAndHashCode()
public void setUseContentEqualsAndHashCode(boolean u)
setUseContentEqualsAndHashCodeDefault(boolean),
it seems that there is no further use for this method, so that it should be removed after ACS 10.1.u - public boolean equalsContent(java.lang.Object o)
public int hashCodeContent()
public boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Object