Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,7 @@ public boolean isCompatible(int type, String typeName, int size,
case Types.VARCHAR:
case Types.CLOB:
case Types.BLOB:
case Types.SQLXML:
return true;
default:
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Copy link
Contributor

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

* under the License.
*/
package org.apache.openjpa.jdbc.schema;

Expand All @@ -27,8 +27,10 @@
*
* @author Abe White
*/
public abstract class Constraint extends ReferenceCounter {
private static final long serialVersionUID = 1L;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO this code

public abstract class Constraint extends ReferenceCounter {
    private static final long serialVersionUID = 1L;

should be restored

@SuppressWarnings("serial")
public abstract class Constraint
extends ReferenceCounter {

private DBIdentifier _name = DBIdentifier.NULL;
private QualifiedDBIdentifier _fullPath = null;
private Table _table = null;
Expand All @@ -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);
}
Expand Down Expand Up @@ -83,7 +84,6 @@ public Table getTable() {
* Return the column's table name.
* @deprecated
*/
@Deprecated
public String getTableName() {
return getTableIdentifier().getName();
}
Expand All @@ -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));
}
Expand All @@ -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();
}
Expand All @@ -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));
}
Expand All @@ -143,7 +140,6 @@ public void setSchemaIdentifier(DBIdentifier schema) {
* Return the column's name.
* @deprecated
*/
@Deprecated
public String getColumnName() {
return getColumnIdentifier().getName();
}
Expand All @@ -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));
}
Expand All @@ -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;
}
Expand All @@ -187,7 +181,6 @@ public DBIdentifier getIdentifier() {
* constraint already belongs to a table.
* @deprecated
*/
@Deprecated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why @Deprecated were removed in this PR?

public void setName(String name) {
setIdentifier(DBIdentifier.newConstraint(name));
}
Expand All @@ -203,7 +196,6 @@ public void setIdentifier(DBIdentifier name) {
* Return the full name of the constraint.
* @deprecated
*/
@Deprecated
public String getFullName() {
return getFullIdentifier().getName();
}
Expand All @@ -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.
Expand All @@ -240,7 +232,6 @@ public void setDeferred(boolean deferred) {
_deferred = deferred;
}

@Override
public String toString() {
if (!getIdentifier().isNull())
return getIdentifier().getName();
Expand All @@ -250,31 +241,48 @@ public String toString() {
return "<" + name.toLowerCase() + ">";
}

@Override
Copy link
Contributor

Choose a reason for hiding this comment

The 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 :)

Copy link
Author

Choose a reason for hiding this comment

The 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;
}


}
Loading