aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRick Curtis2014-06-20 10:01:40 (EDT)
committertware2014-07-29 15:11:28 (EDT)
commita69e2e50593d691682881a4efff67bb0f610a6ea (patch)
tree3bac010bcba4fe2841dc89d46f58ab7d025b11fd
parentd1df0ebc43072daa1cb0d6ada8e969721b96a85d (diff)
downloadeclipselink.runtime-a69e2e50593d691682881a4efff67bb0f610a6ea.zip
eclipselink.runtime-a69e2e50593d691682881a4efff67bb0f610a6ea.tar.gz
eclipselink.runtime-a69e2e50593d691682881a4efff67bb0f610a6ea.tar.bz2
Fix for bug 437760 - Honor spec defined default column name when using an AttributeOverride with no column name specified.
Signed-off-by: Rick Curtis <curtisr7@gmail.com>
-rw-r--r--jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa21/advanced/AdvancedTableCreator.java7
-rw-r--r--jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa21/advanced/Employee.java7
-rw-r--r--jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa21/advanced/EmploymentPeriod.java5
-rw-r--r--jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/mappings/MappingAccessor.java14
4 files changed, 25 insertions, 8 deletions
diff --git a/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa21/advanced/AdvancedTableCreator.java b/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa21/advanced/AdvancedTableCreator.java
index 58982c4..be708e7 100644
--- a/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa21/advanced/AdvancedTableCreator.java
+++ b/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa21/advanced/AdvancedTableCreator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014 Oracle and/or its affiliates, IBM Corporation. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
@@ -24,6 +24,8 @@
* - 382503: Use of @ConstructorResult with createNativeQuery(sqlString, resultSetMapping) results in NullPointerException
* 07/16/2013-2.5.1 Guy Pelletier
* - 412384: Applying Converter for parameterized basic-type for joda-time's DateTime does not work
+ * 06/20/2014-2.5.2 Rick Curtis
+ * - 437760: AttributeOverride with no column name defined doesn't work.
******************************************************************************/
package org.eclipse.persistence.testing.models.jpa21.advanced;
@@ -274,7 +276,8 @@ public class AdvancedTableCreator extends TogglingFastTableCreator {
table.addField(field);
field = new FieldDefinition();
- field.setName("START_DATE");
+ // use 'default' column name based off field of startDate
+ field.setName("STARTDATE");
field.setTypeName("DATE");
field.setSize(23);
field.setShouldAllowNull(true);
diff --git a/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa21/advanced/Employee.java b/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa21/advanced/Employee.java
index 37b29ec..801e8ca 100644
--- a/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa21/advanced/Employee.java
+++ b/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa21/advanced/Employee.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2013, 2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014 Oracle and/or its affiliates, IBM Corporation. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
@@ -16,6 +16,8 @@
* - 374688: JPA 2.1 Converter support
* 02/13/2013-2.5 Guy Pelletier
* - 397772: JPA 2.1 Entity Graph Support (XML support)
+ * 06/20/2014-2.5.2 Rick Curtis
+ * - 437760: AttributeOverride with no column name defined doesn't work.
******************************************************************************/
package org.eclipse.persistence.testing.models.jpa21.advanced;
@@ -301,7 +303,8 @@ public class Employee implements Serializable, Cloneable {
@Embedded
@AttributeOverrides({
- @AttributeOverride(name="startDate", column=@Column(name="START_DATE", nullable=false)),
+ // This should use the spec defined column name, not the column name defined in the EmploymentPeriod
+ @AttributeOverride(name="startDate", column=@Column(nullable=false)),
@AttributeOverride(name="endDate", column=@Column(name="END_DATE", nullable=true))
})
public EmploymentPeriod getPeriod() {
diff --git a/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa21/advanced/EmploymentPeriod.java b/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa21/advanced/EmploymentPeriod.java
index c8dff7c..c9a4f03 100644
--- a/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa21/advanced/EmploymentPeriod.java
+++ b/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa21/advanced/EmploymentPeriod.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014 Oracle and/or its affiliates IBM Corporation. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
@@ -10,6 +10,8 @@
* Contributors:
* 02/08/2012-2.4 Guy Pelletier
* - 350487: JPA 2.1 Specification defined support for Stored Procedure Calls
+ * 06/20/2014-2.5.2 Rick Curtis
+ * - 437760: AttributeOverride with no column name defined doesn't work.
******************************************************************************/
package org.eclipse.persistence.testing.models.jpa21.advanced;
@@ -21,6 +23,7 @@ import javax.persistence.Embeddable;
@Embeddable
public class EmploymentPeriod implements Serializable, Cloneable {
+ @Column(name="NON_DEFAULT_START_DATE")
private Date startDate;
private Date endDate;
diff --git a/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/mappings/MappingAccessor.java b/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/mappings/MappingAccessor.java
index 823f7cd..a8d459d 100644
--- a/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/mappings/MappingAccessor.java
+++ b/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/mappings/MappingAccessor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 1998, 2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2014 Oracle and/or its affiliates, IBM Corporation. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
@@ -89,6 +89,8 @@
* - 389090: JPA 2.1 DDL Generation Support (foreign key metadata support)
* 07/16/2013-2.5.1 Guy Pelletier
* - 412384: Applying Converter for parameterized basic-type for joda-time's DateTime does not work
+ * 06/20/2014-2.5.2 Rick Curtis
+ * - 437760: AttributeOverride with no column name defined doesn't work.
******************************************************************************/
package org.eclipse.persistence.internal.jpa.metadata.accessors.mappings;
@@ -544,7 +546,7 @@ public abstract class MappingAccessor extends MetadataAccessor {
protected DatabaseField getDatabaseField(DatabaseTable defaultTable, String loggingCtx) {
// Check if we have an attribute override first, otherwise process for a column
ColumnMetadata column = hasAttributeOverride(loggingCtx) ? getAttributeOverride(loggingCtx).getColumn() : getColumn(loggingCtx);
-
+
// Get the actual database field and apply any defaults.
DatabaseField field = column.getDatabaseField();
@@ -1473,7 +1475,13 @@ public abstract class MappingAccessor extends MetadataAccessor {
// notation attribute names when looking for the mapping. It will
// traverse the embeddable chain.
MappingAccessor mappingAccessor = embeddableDescriptor.getMappingAccessor(attributeName);
-
+
+ String colName = attributeOverride.getColumn().getName();
+ if (colName == null || colName.isEmpty()) {
+ String prevName = mappingAccessor.getDefaultAttributeName();
+ attributeOverride.getColumn().setName(prevName);
+ }
+
if (mappingAccessor == null) {
throw ValidationException.embeddableAttributeOverrideNotFound(embeddableDescriptor.getJavaClass(), attributeName, getJavaClass(), getAttributeName());
} else if (! mappingAccessor.isBasic()) {