-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
3.2.2 fix OPENJPA-2814 #111
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
* under the License. | ||
*/ | ||
package org.apache.openjpa.jdbc.schema; | ||
|
||
|
@@ -27,8 +27,10 @@ | |
* | ||
* @author Abe White | ||
*/ | ||
public abstract class Constraint extends ReferenceCounter { | ||
private static final long serialVersionUID = 1L; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO this code
should be restored |
||
@SuppressWarnings("serial") | ||
public abstract class Constraint | ||
extends ReferenceCounter { | ||
|
||
private DBIdentifier _name = DBIdentifier.NULL; | ||
private QualifiedDBIdentifier _fullPath = null; | ||
private Table _table = null; | ||
|
@@ -50,7 +52,6 @@ public abstract class Constraint extends ReferenceCounter { | |
* @param table the local table of the constraint | ||
* @deprecated | ||
*/ | ||
@Deprecated | ||
Constraint(String name, Table table) { | ||
this(DBIdentifier.newConstant(name), table); | ||
} | ||
|
@@ -83,7 +84,6 @@ public Table getTable() { | |
* Return the column's table name. | ||
* @deprecated | ||
*/ | ||
@Deprecated | ||
public String getTableName() { | ||
return getTableIdentifier().getName(); | ||
} | ||
|
@@ -97,7 +97,6 @@ public DBIdentifier getTableIdentifier() { | |
* columns whose table object is not set. | ||
* @deprecated | ||
*/ | ||
@Deprecated | ||
public void setTableName(String name) { | ||
setTableIdentifier(DBIdentifier.newTable(name)); | ||
} | ||
|
@@ -109,12 +108,11 @@ public void setTableIdentifier(DBIdentifier name) { | |
_fullPath = null; | ||
} | ||
|
||
|
||
/** | ||
* Return the column table's schema name. | ||
* @deprecated | ||
*/ | ||
@Deprecated | ||
public String getSchemaName() { | ||
return getSchemaIdentifier().getName(); | ||
} | ||
|
@@ -128,7 +126,6 @@ public DBIdentifier getSchemaIdentifier() { | |
* columns whose table object is not set. | ||
* @deprecated | ||
*/ | ||
@Deprecated | ||
public void setSchemaName(String schema) { | ||
setSchemaIdentifier(DBIdentifier.newSchema(schema)); | ||
} | ||
|
@@ -143,7 +140,6 @@ public void setSchemaIdentifier(DBIdentifier schema) { | |
* Return the column's name. | ||
* @deprecated | ||
*/ | ||
@Deprecated | ||
public String getColumnName() { | ||
return getColumnIdentifier().getName(); | ||
} | ||
|
@@ -157,7 +153,6 @@ public DBIdentifier getColumnIdentifier() { | |
* columns whose table object is not set. | ||
* @deprecated | ||
*/ | ||
@Deprecated | ||
public void setColumnName(String name) { | ||
setColumnIdentifier(DBIdentifier.newColumn(name)); | ||
} | ||
|
@@ -172,11 +167,10 @@ public void setColumnIdentifier(DBIdentifier name) { | |
* Return the name of the constraint. | ||
* @deprecated | ||
*/ | ||
@Deprecated | ||
public String getName() { | ||
return getIdentifier().getName(); | ||
} | ||
|
||
public DBIdentifier getIdentifier() { | ||
return _name == null ? DBIdentifier.NULL : _name; | ||
} | ||
|
@@ -187,7 +181,6 @@ public DBIdentifier getIdentifier() { | |
* constraint already belongs to a table. | ||
* @deprecated | ||
*/ | ||
@Deprecated | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why |
||
public void setName(String name) { | ||
setIdentifier(DBIdentifier.newConstraint(name)); | ||
} | ||
|
@@ -203,7 +196,6 @@ public void setIdentifier(DBIdentifier name) { | |
* Return the full name of the constraint. | ||
* @deprecated | ||
*/ | ||
@Deprecated | ||
public String getFullName() { | ||
return getFullIdentifier().getName(); | ||
} | ||
|
@@ -218,8 +210,8 @@ public QualifiedDBIdentifier getQualifiedPath() { | |
public DBIdentifier getFullIdentifier() { | ||
return getQualifiedPath().getIdentifier(); | ||
} | ||
|
||
|
||
/** | ||
* Return whether this constraint is a logical constraint only; i.e. | ||
* if it does not exist in the database. | ||
|
@@ -240,7 +232,6 @@ public void setDeferred(boolean deferred) { | |
_deferred = deferred; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
if (!getIdentifier().isNull()) | ||
return getIdentifier().getName(); | ||
|
@@ -250,31 +241,48 @@ public String toString() { | |
return "<" + name.toLowerCase() + ">"; | ||
} | ||
|
||
@Override | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO previous version of hashcode+equals was more readable also it not clear why to change the order :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I used an auto generated eclipse equals and hashcode. I could mimic the style of the original one indeed. The important thing for me is the fields that are included in the equality and hashcode testing to avoid the mem leak ! |
||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
|
||
Constraint that = (Constraint) o; | ||
|
||
if (_deferred != that._deferred) return false; | ||
if (_name != null ? !_name.equals(that._name) : that._name != null) return false; | ||
if (_fullPath != null ? !_fullPath.equals(that._fullPath) : that._fullPath != null) return false; | ||
if (_table != null ? !_table.equals(that._table) : that._table != null) return false; | ||
if (_tableName != null ? !_tableName.equals(that._tableName) : that._tableName != null) return false; | ||
if (_schemaName != null ? !_schemaName.equals(that._schemaName) : that._schemaName != null) return false; | ||
return _columnName != null ? _columnName.equals(that._columnName) : that._columnName == null; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
int result = _name != null ? _name.hashCode() : 0; | ||
result = 31 * result + (_fullPath != null ? _fullPath.hashCode() : 0); | ||
result = 31 * result + (_table != null ? _table.hashCode() : 0); | ||
result = 31 * result + (_tableName != null ? _tableName.hashCode() : 0); | ||
result = 31 * result + (_schemaName != null ? _schemaName.hashCode() : 0); | ||
result = 31 * result + (_columnName != null ? _columnName.hashCode() : 0); | ||
result = 31 * result + (_deferred ? 1 : 0); | ||
return result; | ||
} | ||
@Override | ||
public int hashCode() { | ||
final int prime = 31; | ||
int result = 1; | ||
result = prime * result + ((_columnName == null) ? 0 : _columnName.hashCode()); | ||
result = prime * result + ((_name == null) ? 0 : _name.hashCode()); | ||
result = prime * result + ((_schemaName == null) ? 0 : _schemaName.hashCode()); | ||
result = prime * result + ((_tableName == null) ? 0 : _tableName.hashCode()); | ||
return result; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) | ||
return true; | ||
if (obj == null) | ||
return false; | ||
if (getClass() != obj.getClass()) | ||
return false; | ||
Constraint other = (Constraint) obj; | ||
if (_columnName == null) { | ||
if (other._columnName != null) | ||
return false; | ||
} else if (!_columnName.equals(other._columnName)) | ||
return false; | ||
if (_name == null) { | ||
if (other._name != null) | ||
return false; | ||
} else if (!_name.equals(other._name)) | ||
return false; | ||
if (_schemaName == null) { | ||
if (other._schemaName != null) | ||
return false; | ||
} else if (!_schemaName.equals(other._schemaName)) | ||
return false; | ||
if (_tableName == null) { | ||
if (other._tableName != null) | ||
return false; | ||
} else if (!_tableName.equals(other._tableName)) | ||
return false; | ||
return true; | ||
} | ||
|
||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe all trailing spaces should be removed