This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
View | Details | Raw Unified | Return to bug 312132
Collapse All | Expand All

(-)foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/indirection/WeavedObjectBasicIndirectionPolicy.java (-2 / +16 lines)
Lines 75-84 Link Here
75
            // The parameter type for the set method must always be the return type of the get method.
75
            // The parameter type for the set method must always be the return type of the get method.
76
            Class[] parameterTypes = new Class[1];
76
            Class[] parameterTypes = new Class[1];
77
            parameterTypes[0] = sourceMapping.getReferenceClass();
77
            parameterTypes[0] = sourceMapping.getReferenceClass();
78
78
            try {
79
            try {
79
                setMethod = Helper.getDeclaredMethod(sourceMapping.getDescriptor().getJavaClass(), setMethodName, parameterTypes);
80
                setMethod = Helper.getDeclaredMethod(sourceMapping.getDescriptor().getJavaClass(), setMethodName, parameterTypes);
80
            } catch (NoSuchMethodException e){
81
            } catch (NoSuchMethodException e) {
81
                throw DescriptorException.errorAccessingSetMethodOfEntity(sourceMapping.getDescriptor().getJavaClass(), setMethodName ,sourceMapping.getDescriptor(), e);
82
                // As a last ditch effort, change the parameter type to Object.class. 
83
                // If the model uses generics:
84
                //   public T getStuntDouble()
85
                //   public void setStuntDouble(T)
86
                // The weaved methods will be:
87
                //   public Object getStuntDouble() and 
88
                //   public void setStuntDouble(Object)
89
                try {
90
                    parameterTypes[0] = Object.class;
91
                    setMethod = Helper.getDeclaredMethod(sourceMapping.getDescriptor().getJavaClass(), setMethodName, parameterTypes);    
92
                } catch (NoSuchMethodException ee) {
93
                    // Throw the original exception.
94
                    throw DescriptorException.errorAccessingSetMethodOfEntity(sourceMapping.getDescriptor().getJavaClass(), setMethodName, sourceMapping.getDescriptor(), e);
95
                }
82
            }
96
            }
83
        }
97
        }
84
        return setMethod;
98
        return setMethod;
(-)jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/inherited/Alpine.java (-1 / +3 lines)
Lines 13-18 Link Here
13
 *       - 232975: Failure when attribute type is generic
13
 *       - 232975: Failure when attribute type is generic
14
 *     07/15/2010-2.2 Guy Pelletier 
14
 *     07/15/2010-2.2 Guy Pelletier 
15
 *       -311395 : Multiple lifecycle callback methods for the same lifecycle event
15
 *       -311395 : Multiple lifecycle callback methods for the same lifecycle event
16
 *     08/11/2010-2.2 Guy Pelletier 
17
 *       - 312123: JPA: Validation error during Id processing on parameterized generic OneToOne Entity relationship from MappedSuperclass
16
 ******************************************************************************/  
18
 ******************************************************************************/  
17
package org.eclipse.persistence.testing.models.jpa.inherited;
19
package org.eclipse.persistence.testing.models.jpa.inherited;
18
20
Lines 40-46 Link Here
40
  pkColumnName="SEQ_NAME", 
42
  pkColumnName="SEQ_NAME", 
41
  valueColumnName="SEQ_COUNT",
43
  valueColumnName="SEQ_COUNT",
42
  pkColumnValue="BEVERAGE_SEQ")
44
  pkColumnValue="BEVERAGE_SEQ")
43
public class Alpine extends Beer<Integer, Double> implements Cloneable, Serializable {
45
public class Alpine extends Beer<Integer, Double, Alpine> implements Cloneable, Serializable {
44
    public enum Classification { STRONG, BITTER, SWEET, NONE }
46
    public enum Classification { STRONG, BITTER, SWEET, NONE }
45
    
47
    
46
    private Date bestBeforeDate;
48
    private Date bestBeforeDate;
(-)jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/inherited/Becks.java (-1 / +3 lines)
Lines 10-15 Link Here
10
 * Contributors:
10
 * Contributors:
11
 *     03/27/2009-2.0 Guy Pelletier 
11
 *     03/27/2009-2.0 Guy Pelletier 
12
 *       - 241413: JPA 2.0 Add EclipseLink support for Map type attributes
12
 *       - 241413: JPA 2.0 Add EclipseLink support for Map type attributes
13
 *     08/11/2010-2.2 Guy Pelletier 
14
 *       - 312123: JPA: Validation error during Id processing on parameterized generic OneToOne Entity relationship from MappedSuperclass
13
 ******************************************************************************/  
15
 ******************************************************************************/  
14
package org.eclipse.persistence.testing.models.jpa.inherited;
16
package org.eclipse.persistence.testing.models.jpa.inherited;
15
17
Lines 18-24 Link Here
18
20
19
@Entity
21
@Entity
20
@Table(name="CMP3_BECKS")
22
@Table(name="CMP3_BECKS")
21
public class Becks extends Beer<Integer, Double> implements Cloneable {
23
public class Becks extends Beer<Integer, Double, Becks> implements Cloneable {
22
    public Becks() {}
24
    public Becks() {}
23
    
25
    
24
    public Becks clone() throws CloneNotSupportedException {
26
    public Becks clone() throws CloneNotSupportedException {
(-)jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/inherited/Beer.java (-1 / +16 lines)
Lines 13-18 Link Here
13
 *       - 232975: Failure when attribute type is generic
13
 *       - 232975: Failure when attribute type is generic
14
 *     07/15/2010-2.2 Guy Pelletier 
14
 *     07/15/2010-2.2 Guy Pelletier 
15
 *       -311395 : Multiple lifecycle callback methods for the same lifecycle event
15
 *       -311395 : Multiple lifecycle callback methods for the same lifecycle event
16
 *     08/11/2010-2.2 Guy Pelletier 
17
 *       - 312123: JPA: Validation error during Id processing on parameterized generic OneToOne Entity relationship from MappedSuperclass
16
 ******************************************************************************/  
18
 ******************************************************************************/  
17
package org.eclipse.persistence.testing.models.jpa.inherited;
19
package org.eclipse.persistence.testing.models.jpa.inherited;
18
20
Lines 21-26 Link Here
21
import javax.persistence.PostPersist;
23
import javax.persistence.PostPersist;
22
import javax.persistence.Version;
24
import javax.persistence.Version;
23
import javax.persistence.ManyToOne;
25
import javax.persistence.ManyToOne;
26
import javax.persistence.OneToOne;
24
import javax.persistence.PrePersist;
27
import javax.persistence.PrePersist;
25
import javax.persistence.JoinColumn;
28
import javax.persistence.JoinColumn;
26
import javax.persistence.MappedSuperclass;
29
import javax.persistence.MappedSuperclass;
Lines 34-43 Link Here
34
37
35
@MappedSuperclass
38
@MappedSuperclass
36
@ExistenceChecking(CHECK_CACHE)
39
@ExistenceChecking(CHECK_CACHE)
37
public class Beer<G, H> extends Beverage<G> {
40
public class Beer<G, H, I> extends Beverage<G> {
38
    private Timestamp version;
41
    private Timestamp version;
39
    private H alcoholContent;
42
    private H alcoholContent;
40
    private BeerConsumer beerConsumer;
43
    private BeerConsumer beerConsumer;
44
    private I beerDouble;
41
    
45
    
42
    public static int BEER_PRE_PERSIST_COUNT = 0;
46
    public static int BEER_PRE_PERSIST_COUNT = 0;
43
    public static int BEER_POST_PERSIST_COUNT = 0;
47
    public static int BEER_POST_PERSIST_COUNT = 0;
Lines 72-77 Link Here
72
        return beerConsumer;
76
        return beerConsumer;
73
    }
77
    }
74
    
78
    
79
    @OneToOne(fetch=LAZY)
80
    //@OneToOne
81
    @JoinColumn(name="BD_ID")
82
    public I getBeerDouble() {
83
        return beerDouble;
84
    }
85
    
75
    @Version
86
    @Version
76
    public Timestamp getVersion() {
87
    public Timestamp getVersion() {
77
        return version;
88
        return version;
Lines 85-90 Link Here
85
        this.beerConsumer = beerConsumer;
96
        this.beerConsumer = beerConsumer;
86
    }
97
    }
87
    
98
    
99
    public void setBeerDouble(I beerDouble) {
100
        this.beerDouble = beerDouble;
101
    }
102
    
88
    public void setVersion(Timestamp version) {
103
    public void setVersion(Timestamp version) {
89
        this.version = version;
104
        this.version = version;
90
    }
105
    }
(-)jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/inherited/Blue.java (-1 / +3 lines)
Lines 13-18 Link Here
13
 *       - 230213: ValidationException when mapping to attribute in MappedSuperClass
13
 *       - 230213: ValidationException when mapping to attribute in MappedSuperClass
14
 *     06/20/2008-1.0 Guy Pelletier 
14
 *     06/20/2008-1.0 Guy Pelletier 
15
 *       - 232975: Failure when attribute type is generic
15
 *       - 232975: Failure when attribute type is generic
16
 *     08/11/2010-2.2 Guy Pelletier 
17
 *       - 312123: JPA: Validation error during Id processing on parameterized generic OneToOne Entity relationship from MappedSuperclass
16
 ******************************************************************************/  
18
 ******************************************************************************/  
17
package org.eclipse.persistence.testing.models.jpa.inherited;
19
package org.eclipse.persistence.testing.models.jpa.inherited;
18
20
Lines 29-35 Link Here
29
@Entity
31
@Entity
30
@Inheritance(strategy=SINGLE_TABLE)
32
@Inheritance(strategy=SINGLE_TABLE)
31
@Table(name="CMP3_BLUE")
33
@Table(name="CMP3_BLUE")
32
public class Blue extends Beer<BigDecimal, Float> implements Bluish<BigInteger, BigInteger>, Cloneable  {
34
public class Blue extends Beer<BigDecimal, Float, Blue> implements Bluish<BigInteger, BigInteger>, Cloneable  {
33
    private BigInteger uniqueKey;
35
    private BigInteger uniqueKey;
34
    public Blue() {}
36
    public Blue() {}
35
    
37
    
(-)jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/inherited/Canadian.java (-1 / +3 lines)
Lines 13-18 Link Here
13
 *       - 230213: ValidationException when mapping to attribute in MappedSuperClass
13
 *       - 230213: ValidationException when mapping to attribute in MappedSuperClass
14
 *     06/20/2008-1.0 Guy Pelletier 
14
 *     06/20/2008-1.0 Guy Pelletier 
15
 *       - 232975: Failure when attribute type is generic
15
 *       - 232975: Failure when attribute type is generic
16
 *     08/11/2010-2.2 Guy Pelletier 
17
 *       - 312123: JPA: Validation error during Id processing on parameterized generic OneToOne Entity relationship from MappedSuperclass
16
 ******************************************************************************/  
18
 ******************************************************************************/  
17
package org.eclipse.persistence.testing.models.jpa.inherited;
19
package org.eclipse.persistence.testing.models.jpa.inherited;
18
20
Lines 32-38 Link Here
32
@Table(name="CMP3_CANADIAN")
34
@Table(name="CMP3_CANADIAN")
33
@AssociationOverride(name="beerConsumer", joinColumns=@JoinColumn(name="CONSUMER_ID"))
35
@AssociationOverride(name="beerConsumer", joinColumns=@JoinColumn(name="CONSUMER_ID"))
34
@ExistenceChecking(CHECK_DATABASE)
36
@ExistenceChecking(CHECK_DATABASE)
35
public class Canadian extends Beer<Integer, Double> {
37
public class Canadian extends Beer<Integer, Double, Canadian> {
36
    public enum Flavor { LAGER, LIGHT, ICE, DRY }
38
    public enum Flavor { LAGER, LIGHT, ICE, DRY }
37
39
38
    private Flavor flavor;
40
    private Flavor flavor;
(-)jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/inherited/Corona.java (-1 / +3 lines)
Lines 10-15 Link Here
10
 * Contributors:
10
 * Contributors:
11
 *     03/27/2009-2.0 Guy Pelletier 
11
 *     03/27/2009-2.0 Guy Pelletier 
12
 *       - 241413: JPA 2.0 Add EclipseLink support for Map type attributes
12
 *       - 241413: JPA 2.0 Add EclipseLink support for Map type attributes
13
 *     08/11/2010-2.2 Guy Pelletier 
14
 *       - 312123: JPA: Validation error during Id processing on parameterized generic OneToOne Entity relationship from MappedSuperclass
13
 ******************************************************************************/  
15
 ******************************************************************************/  
14
package org.eclipse.persistence.testing.models.jpa.inherited;
16
package org.eclipse.persistence.testing.models.jpa.inherited;
15
17
Lines 18-24 Link Here
18
20
19
@Entity
21
@Entity
20
@Table(name="CMP3_CORONA")
22
@Table(name="CMP3_CORONA")
21
public class Corona extends Beer<Integer, Double> implements Cloneable {
23
public class Corona extends Beer<Integer, Double, Corona> implements Cloneable {
22
    public Corona() {}
24
    public Corona() {}
23
    
25
    
24
    public Corona clone() throws CloneNotSupportedException {
26
    public Corona clone() throws CloneNotSupportedException {
(-)jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/inherited/Heineken.java (-1 / +3 lines)
Lines 10-15 Link Here
10
 * Contributors:
10
 * Contributors:
11
 *     03/27/2009-2.0 Guy Pelletier 
11
 *     03/27/2009-2.0 Guy Pelletier 
12
 *       - 241413: JPA 2.0 Add EclipseLink support for Map type attributes
12
 *       - 241413: JPA 2.0 Add EclipseLink support for Map type attributes
13
 *     08/11/2010-2.2 Guy Pelletier 
14
 *       - 312123: JPA: Validation error during Id processing on parameterized generic OneToOne Entity relationship from MappedSuperclass
13
 ******************************************************************************/  
15
 ******************************************************************************/  
14
package org.eclipse.persistence.testing.models.jpa.inherited;
16
package org.eclipse.persistence.testing.models.jpa.inherited;
15
17
Lines 19-25 Link Here
19
21
20
@Entity
22
@Entity
21
@Table(name="CMP3_HEINEKEN")
23
@Table(name="CMP3_HEINEKEN")
22
public class Heineken extends Beer<Integer, Double> implements Cloneable {
24
public class Heineken extends Beer<Integer, Double, Heineken> implements Cloneable {
23
    public Heineken() {}
25
    public Heineken() {}
24
    
26
    
25
    public Heineken clone() throws CloneNotSupportedException {
27
    public Heineken clone() throws CloneNotSupportedException {
(-)jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/inherited/InheritedTableManager.java (+68 lines)
Lines 35-40 Link Here
35
 *       - 300458: EclispeLink should throw a more specific exception than NPE
35
 *       - 300458: EclispeLink should throw a more specific exception than NPE
36
 *     07/16/2010-2.2 Guy Pelletier 
36
 *     07/16/2010-2.2 Guy Pelletier 
37
 *       - 260296: mixed access with no Transient annotation does not result in error
37
 *       - 260296: mixed access with no Transient annotation does not result in error
38
 *     08/11/2010-2.2 Guy Pelletier 
39
 *       - 312123: JPA: Validation error during Id processing on parameterized generic OneToOne Entity relationship from MappedSuperclass
38
 ******************************************************************************/  
40
 ******************************************************************************/  
39
package org.eclipse.persistence.testing.models.jpa.inherited;
41
package org.eclipse.persistence.testing.models.jpa.inherited;
40
42
Lines 155-160 Link Here
155
        BEER_CONSUMER_ID_field.setForeignKeyFieldName("CMP3_CONSUMER.ID");
157
        BEER_CONSUMER_ID_field.setForeignKeyFieldName("CMP3_CONSUMER.ID");
156
        table.addField(BEER_CONSUMER_ID_field);
158
        table.addField(BEER_CONSUMER_ID_field);
157
        
159
        
160
        FieldDefinition BEER_DOUBLE_ID_field = new FieldDefinition();
161
        BEER_DOUBLE_ID_field.setName("BD_ID");
162
        BEER_DOUBLE_ID_field.setTypeName("NUMERIC");
163
        BEER_DOUBLE_ID_field.setSize(15);
164
        BEER_DOUBLE_ID_field.setIsPrimaryKey(false);
165
        BEER_DOUBLE_ID_field.setUnique(false);
166
        BEER_DOUBLE_ID_field.setIsIdentity(false);
167
        BEER_DOUBLE_ID_field.setShouldAllowNull(true);
168
        BEER_DOUBLE_ID_field.setForeignKeyFieldName("CMP3_ALPINE.ID");
169
        table.addField(BEER_DOUBLE_ID_field);
170
        
158
        FieldDefinition VERSION_field = new FieldDefinition();
171
        FieldDefinition VERSION_field = new FieldDefinition();
159
        VERSION_field.setName("VERSION");
172
        VERSION_field.setName("VERSION");
160
        VERSION_field.setTypeName("DATETIME");
173
        VERSION_field.setTypeName("DATETIME");
Lines 264-269 Link Here
264
        BEER_CONSUMER_ID_field.setForeignKeyFieldName("CMP3_CONSUMER.ID");
277
        BEER_CONSUMER_ID_field.setForeignKeyFieldName("CMP3_CONSUMER.ID");
265
        table.addField(BEER_CONSUMER_ID_field);
278
        table.addField(BEER_CONSUMER_ID_field);
266
        
279
        
280
        FieldDefinition BEER_DOUBLE_ID_field = new FieldDefinition();
281
        BEER_DOUBLE_ID_field.setName("BD_ID");
282
        BEER_DOUBLE_ID_field.setTypeName("NUMERIC");
283
        BEER_DOUBLE_ID_field.setSize(15);
284
        BEER_DOUBLE_ID_field.setIsPrimaryKey(false);
285
        BEER_DOUBLE_ID_field.setUnique(false);
286
        BEER_DOUBLE_ID_field.setIsIdentity(false);
287
        BEER_DOUBLE_ID_field.setShouldAllowNull(true);
288
        BEER_DOUBLE_ID_field.setForeignKeyFieldName("CMP3_BECKS.ID");
289
        table.addField(BEER_DOUBLE_ID_field);
290
        
267
        FieldDefinition VERSION_field = new FieldDefinition();
291
        FieldDefinition VERSION_field = new FieldDefinition();
268
        VERSION_field.setName("VERSION");
292
        VERSION_field.setName("VERSION");
269
        VERSION_field.setTypeName("DATETIME");
293
        VERSION_field.setTypeName("DATETIME");
Lines 453-458 Link Here
453
        BEER_CONSUMER_ID_field.setForeignKeyFieldName("CMP3_CONSUMER.ID");
477
        BEER_CONSUMER_ID_field.setForeignKeyFieldName("CMP3_CONSUMER.ID");
454
        table.addField(BEER_CONSUMER_ID_field);
478
        table.addField(BEER_CONSUMER_ID_field);
455
        
479
        
480
        FieldDefinition BEER_DOUBLE_ID_field = new FieldDefinition();
481
        BEER_DOUBLE_ID_field.setName("BD_ID");
482
        BEER_DOUBLE_ID_field.setTypeName("NUMERIC");
483
        BEER_DOUBLE_ID_field.setSize(15);
484
        BEER_DOUBLE_ID_field.setIsPrimaryKey(false);
485
        BEER_DOUBLE_ID_field.setUnique(false);
486
        BEER_DOUBLE_ID_field.setIsIdentity(false);
487
        BEER_DOUBLE_ID_field.setShouldAllowNull(true);
488
        BEER_DOUBLE_ID_field.setForeignKeyFieldName("CMP3_BLUE.ID");
489
        table.addField(BEER_DOUBLE_ID_field);
490
        
456
        FieldDefinition VERSION_field = new FieldDefinition();
491
        FieldDefinition VERSION_field = new FieldDefinition();
457
        VERSION_field.setName("VERSION");
492
        VERSION_field.setName("VERSION");
458
        VERSION_field.setTypeName("DATETIME");
493
        VERSION_field.setTypeName("DATETIME");
Lines 552-557 Link Here
552
        BEER_CONSUMER_ID_field.setForeignKeyFieldName("CMP3_CONSUMER.ID");
587
        BEER_CONSUMER_ID_field.setForeignKeyFieldName("CMP3_CONSUMER.ID");
553
        table.addField(BEER_CONSUMER_ID_field);
588
        table.addField(BEER_CONSUMER_ID_field);
554
        
589
        
590
        FieldDefinition BEER_DOUBLE_ID_field = new FieldDefinition();
591
        BEER_DOUBLE_ID_field.setName("BD_ID");
592
        BEER_DOUBLE_ID_field.setTypeName("NUMERIC");
593
        BEER_DOUBLE_ID_field.setSize(15);
594
        BEER_DOUBLE_ID_field.setIsPrimaryKey(false);
595
        BEER_DOUBLE_ID_field.setUnique(false);
596
        BEER_DOUBLE_ID_field.setIsIdentity(false);
597
        BEER_DOUBLE_ID_field.setShouldAllowNull(true);
598
        BEER_DOUBLE_ID_field.setForeignKeyFieldName("CMP3_CANADIAN.ID");
599
        table.addField(BEER_DOUBLE_ID_field);
600
        
555
        FieldDefinition fieldPROPERTIES = new FieldDefinition();
601
        FieldDefinition fieldPROPERTIES = new FieldDefinition();
556
        fieldPROPERTIES.setName("PROPERTIES");
602
        fieldPROPERTIES.setName("PROPERTIES");
557
        fieldPROPERTIES.setTypeName("LONG RAW");
603
        fieldPROPERTIES.setTypeName("LONG RAW");
Lines 631-636 Link Here
631
        BEER_CONSUMER_ID_field.setForeignKeyFieldName("CMP3_CONSUMER.ID");
677
        BEER_CONSUMER_ID_field.setForeignKeyFieldName("CMP3_CONSUMER.ID");
632
        table.addField(BEER_CONSUMER_ID_field);
678
        table.addField(BEER_CONSUMER_ID_field);
633
        
679
        
680
        FieldDefinition BEER_DOUBLE_ID_field = new FieldDefinition();
681
        BEER_DOUBLE_ID_field.setName("BD_ID");
682
        BEER_DOUBLE_ID_field.setTypeName("NUMERIC");
683
        BEER_DOUBLE_ID_field.setSize(15);
684
        BEER_DOUBLE_ID_field.setIsPrimaryKey(false);
685
        BEER_DOUBLE_ID_field.setUnique(false);
686
        BEER_DOUBLE_ID_field.setIsIdentity(false);
687
        BEER_DOUBLE_ID_field.setShouldAllowNull(true);
688
        BEER_DOUBLE_ID_field.setForeignKeyFieldName("CMP3_CORONA.ID");
689
        table.addField(BEER_DOUBLE_ID_field);
690
        
634
        FieldDefinition VERSION_field = new FieldDefinition();
691
        FieldDefinition VERSION_field = new FieldDefinition();
635
        VERSION_field.setName("VERSION");
692
        VERSION_field.setName("VERSION");
636
        VERSION_field.setTypeName("DATETIME");
693
        VERSION_field.setTypeName("DATETIME");
Lines 792-797 Link Here
792
        BEER_CONSUMER_ID_field.setForeignKeyFieldName("CMP3_CONSUMER.ID");
849
        BEER_CONSUMER_ID_field.setForeignKeyFieldName("CMP3_CONSUMER.ID");
793
        table.addField(BEER_CONSUMER_ID_field);
850
        table.addField(BEER_CONSUMER_ID_field);
794
        
851
        
852
        FieldDefinition BEER_DOUBLE_ID_field = new FieldDefinition();
853
        BEER_DOUBLE_ID_field.setName("BD_ID");
854
        BEER_DOUBLE_ID_field.setTypeName("NUMERIC");
855
        BEER_DOUBLE_ID_field.setSize(15);
856
        BEER_DOUBLE_ID_field.setIsPrimaryKey(false);
857
        BEER_DOUBLE_ID_field.setUnique(false);
858
        BEER_DOUBLE_ID_field.setIsIdentity(false);
859
        BEER_DOUBLE_ID_field.setShouldAllowNull(true);
860
        BEER_DOUBLE_ID_field.setForeignKeyFieldName("CMP3_HEINEKEN.ID");
861
        table.addField(BEER_DOUBLE_ID_field);
862
        
795
        FieldDefinition VERSION_field = new FieldDefinition();
863
        FieldDefinition VERSION_field = new FieldDefinition();
796
        VERSION_field.setName("VERSION");
864
        VERSION_field.setName("VERSION");
797
        VERSION_field.setTypeName("DATETIME");
865
        VERSION_field.setTypeName("DATETIME");
(-)jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/classes/EntityAccessor.java (-2 / +4 lines)
Lines 69-74 Link Here
69
 *       - 308729: Persistent Unit deployment exception when mappedsuperclass has no annotations but has lifecycle callbacks
69
 *       - 308729: Persistent Unit deployment exception when mappedsuperclass has no annotations but has lifecycle callbacks
70
 *     07/05/2010-2.1.1 Guy Pelletier 
70
 *     07/05/2010-2.1.1 Guy Pelletier 
71
 *       - 317708: Exception thrown when using LAZY fetch on VIRTUAL mapping
71
 *       - 317708: Exception thrown when using LAZY fetch on VIRTUAL mapping
72
 *     08/11/2010-2.2 Guy Pelletier 
73
 *       - 312123: JPA: Validation error during Id processing on parameterized generic OneToOne Entity relationship from MappedSuperclass
72
 ******************************************************************************/  
74
 ******************************************************************************/  
73
package org.eclipse.persistence.internal.jpa.metadata.accessors.classes;
75
package org.eclipse.persistence.internal.jpa.metadata.accessors.classes;
74
76
Lines 203-209 Link Here
203
                    
205
                    
204
                    // 266912: process and store mappedSuperclass descriptors on 
206
                    // 266912: process and store mappedSuperclass descriptors on 
205
                    // the project for later use by the Metamodel API.
207
                    // the project for later use by the Metamodel API.
206
                    getProject().addMetamodelMappedSuperclass(metadataClass, new MappedSuperclassAccessor(metadataClass.getAnnotation(MappedSuperclass.class), metadataClass, getProject()));
208
                    getProject().addMetamodelMappedSuperclass(new MappedSuperclassAccessor(metadataClass.getAnnotation(MappedSuperclass.class), metadataClass, getProject()), getDescriptor());
207
                }
209
                }
208
            }
210
            }
209
        } else {
211
        } else {
Lines 222-228 Link Here
222
                // project for later use by the Metamodel API Note: we must 
224
                // project for later use by the Metamodel API Note: we must 
223
                // again reload our accessor from XML or we will be sharing 
225
                // again reload our accessor from XML or we will be sharing 
224
                // instances of the descriptor
226
                // instances of the descriptor
225
                getProject().addMetamodelMappedSuperclass(metadataClass, reloadMappedSuperclass(accessor,  new MetadataDescriptor(metadataClass)));
227
                getProject().addMetamodelMappedSuperclass(reloadMappedSuperclass(accessor,  new MetadataDescriptor(metadataClass)), getDescriptor());
226
            } else {
228
            } else {
227
                m_mappedSuperclasses.add(accessor);
229
                m_mappedSuperclasses.add(accessor);
228
            }
230
            }
(-)jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/mappings/RelationshipAccessor.java (-8 / +25 lines)
Lines 37-42 Link Here
37
 *       - 309856: MappedSuperclasses from XML are not being initialized properly
37
 *       - 309856: MappedSuperclasses from XML are not being initialized properly
38
 *     06/14/2010-2.2 Guy Pelletier 
38
 *     06/14/2010-2.2 Guy Pelletier 
39
 *       - 264417: Table generation is incorrect for JoinTables in AssociationOverrides
39
 *       - 264417: Table generation is incorrect for JoinTables in AssociationOverrides
40
 *     08/11/2010-2.2 Guy Pelletier 
41
 *       - 312123: JPA: Validation error during Id processing on parameterized generic OneToOne Entity relationship from MappedSuperclass
40
 ******************************************************************************/  
42
 ******************************************************************************/  
41
package org.eclipse.persistence.internal.jpa.metadata.accessors.mappings;
43
package org.eclipse.persistence.internal.jpa.metadata.accessors.mappings;
42
44
Lines 72-77 Link Here
72
74
73
import org.eclipse.persistence.internal.jpa.metadata.accessors.classes.ClassAccessor;
75
import org.eclipse.persistence.internal.jpa.metadata.accessors.classes.ClassAccessor;
74
import org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataAccessibleObject;
76
import org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataAccessibleObject;
77
import org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataAnnotatedElement;
75
import org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataAnnotation;
78
import org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataAnnotation;
76
import org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataClass;
79
import org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataClass;
77
80
Lines 429-447 Link Here
429
      */
432
      */
430
    @Override
433
    @Override
431
    public MetadataDescriptor getReferenceDescriptor() {
434
    public MetadataDescriptor getReferenceDescriptor() {
432
        MetadataDescriptor descriptor;
435
        MetadataDescriptor referenceDescriptor;
433
       
436
        
434
        try {
437
        // When processing metamodel mapped superclasses, we don't have the 
435
            descriptor = super.getReferenceDescriptor();
438
        // luxury of a full type context as we would during regular metadata
436
        } catch (Exception exception) {
439
        // processing (e.g. to figure out generic types). The metamodel mapped
437
            descriptor = null;
440
        // superclass descriptors must therefore rely on a real child descriptor
441
        // to extract this information and process correctly. When a type is 
442
        // unknown, the reference class name currently defaults to java.lang.string.
443
        // @see MetadataAnnotatedElement getRawClass(MetadataDescriptor)
444
        if (getDescriptor().isMappedSuperclass() && getReferenceClassName().equals(MetadataAnnotatedElement.DEFAULT_RAW_CLASS)) {
445
            MappingAccessor childMappingAccessor = getDescriptor().getMetamodelMappedSuperclassChildDescriptor().getMappingAccessor(getAttributeName());
446
            referenceDescriptor = childMappingAccessor.getReferenceDescriptor();
447
            
448
            if (referenceDescriptor.isInheritanceSubclass()) {
449
                referenceDescriptor = referenceDescriptor.getInheritanceRootDescriptor();
450
            }
451
        } else {
452
            ClassAccessor accessor = getProject().getAccessor(getReferenceClassName());
453
            referenceDescriptor = (accessor != null) ? accessor.getDescriptor() : null; 
438
        }
454
        }
439
       
455
       
440
        if (descriptor == null || descriptor.isEmbeddable() || descriptor.isEmbeddableCollection()) {
456
        // Validate the reference descriptor is valid.
457
        if (referenceDescriptor == null || referenceDescriptor.isEmbeddable() || referenceDescriptor.isEmbeddableCollection()) {
441
            throw ValidationException.nonEntityTargetInRelationship(getJavaClass(), getReferenceClass(), getAnnotatedElement());
458
            throw ValidationException.nonEntityTargetInRelationship(getJavaClass(), getReferenceClass(), getAnnotatedElement());
442
        }
459
        }
443
       
460
       
444
        return descriptor;
461
        return referenceDescriptor;
445
    }
462
    }
446
    
463
    
447
    /**
464
    /**
(-)jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/metadata/accessors/objects/MetadataAnnotatedElement.java (-2 / +15 lines)
Lines 29-34 Link Here
29
 *          in support of the custom descriptors holding mappings required by the Metamodel
29
 *          in support of the custom descriptors holding mappings required by the Metamodel
30
 *     03/08/2010-2.1 Guy Pelletier 
30
 *     03/08/2010-2.1 Guy Pelletier 
31
 *       - 303632: Add attribute-type for mapping attributes to EclipseLink-ORM
31
 *       - 303632: Add attribute-type for mapping attributes to EclipseLink-ORM
32
 *     08/11/2010-2.2 Guy Pelletier 
33
 *       - 312123: JPA: Validation error during Id processing on parameterized generic OneToOne Entity relationship from MappedSuperclass
32
 ******************************************************************************/
34
 ******************************************************************************/
33
package org.eclipse.persistence.internal.jpa.metadata.accessors.objects;
35
package org.eclipse.persistence.internal.jpa.metadata.accessors.objects;
34
36
Lines 77-82 Link Here
77
 */
79
 */
78
@SuppressWarnings("deprecation")
80
@SuppressWarnings("deprecation")
79
public class MetadataAnnotatedElement extends MetadataAccessibleObject {
81
public class MetadataAnnotatedElement extends MetadataAccessibleObject {
82
    public static final String DEFAULT_RAW_CLASS = "java.lang.String";
80
    public static final String JPA_PERSISTENCE_PACKAGE_PREFIX = "javax.persistence";
83
    public static final String JPA_PERSISTENCE_PACKAGE_PREFIX = "javax.persistence";
81
    public static final String ECLIPSELINK_PERSISTENCE_PACKAGE_PREFIX = "org.eclipse.persistence.annotations";
84
    public static final String ECLIPSELINK_PERSISTENCE_PACKAGE_PREFIX = "org.eclipse.persistence.annotations";
82
    
85
    
Lines 269-277 Link Here
269
    public MetadataClass getRawClass(MetadataDescriptor descriptor) {
272
    public MetadataClass getRawClass(MetadataDescriptor descriptor) {
270
        if (m_rawClass == null) {
273
        if (m_rawClass == null) {
271
            if (isGenericType()) {
274
            if (isGenericType()) {
272
                String type = descriptor.getGenericType(getGenericType().get(0));
275
                // Seems that every generic annotated element has the T char 
276
                // in the 0 position. The actual generic type is therefore in
277
                // the 1 position.
278
                String type = descriptor.getGenericType(getGenericType().get(1));
273
                if (type == null) {
279
                if (type == null) {
274
                    return getMetadataClass("java.lang.String");
280
                    // If the generic type can not be resolved, take a stab 
281
                    // by returning a default class. One known case where this
282
                    // will hit is when processing generic accessors from a 
283
                    // mapped superclass for the internal meta model. I wonder
284
                    // if returning null here would be better? Forcing the  
285
                    // caller to have a plan B in place.
286
                    // @see e.g. RelationshipAccessor.getReferenceDescriptor()
287
                    return getMetadataClass(DEFAULT_RAW_CLASS);
275
                }
288
                }
276
                return getMetadataClass(type);
289
                return getMetadataClass(type);
277
            }
290
            }
(-)jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/metadata/MetadataDescriptor.java (-27 / +49 lines)
Lines 72-77 Link Here
72
 *       - 260296: mixed access with no Transient annotation does not result in error
72
 *       - 260296: mixed access with no Transient annotation does not result in error
73
 *     08/04/2010-2.1.1 Guy Pelletier
73
 *     08/04/2010-2.1.1 Guy Pelletier
74
 *       - 315782: JPA2 derived identity metadata processing validation doesn't account for autoboxing
74
 *       - 315782: JPA2 derived identity metadata processing validation doesn't account for autoboxing
75
 *     08/11/2010-2.2 Guy Pelletier 
76
 *       - 312123: JPA: Validation error during Id processing on parameterized generic OneToOne Entity relationship from MappedSuperclass
75
 ******************************************************************************/  
77
 ******************************************************************************/  
76
package org.eclipse.persistence.internal.jpa.metadata;
78
package org.eclipse.persistence.internal.jpa.metadata;
77
79
Lines 149-155 Link Here
149
    private Boolean m_usesCascadedOptimisticLocking;
151
    private Boolean m_usesCascadedOptimisticLocking;
150
    
152
    
151
    private ClassAccessor m_classAccessor;
153
    private ClassAccessor m_classAccessor;
152
    private RelationalDescriptor m_descriptor;
153
    private DatabaseTable m_primaryTable;
154
    private DatabaseTable m_primaryTable;
154
    // The embedded id accessor for this descriptor if one exists.
155
    // The embedded id accessor for this descriptor if one exists.
155
    private EmbeddedIdAccessor m_embeddedIdAccessor;
156
    private EmbeddedIdAccessor m_embeddedIdAccessor;
Lines 180-185 Link Here
180
    private MetadataDescriptor m_inheritanceRootDescriptor;
181
    private MetadataDescriptor m_inheritanceRootDescriptor;
181
    // This is our immediate parent's descriptor. Which may also be the root. 
182
    // This is our immediate parent's descriptor. Which may also be the root. 
182
    private MetadataDescriptor m_inheritanceParentDescriptor;
183
    private MetadataDescriptor m_inheritanceParentDescriptor;
184
    // Used only for a mapped superclass descriptor. Allows us to look up
185
    // more specific types when a mapping may use a generic specification.
186
    // Note: a mapped superclass can not be discovered without the help of 
187
    // an entity accessor. Therefore, if this descriptor is to a mapped super
188
    // class, the child entity accessor will (and must) be set.
189
    private MetadataDescriptor m_metamodelMappedSuperclassChildDescriptor;
190
    private RelationalDescriptor m_descriptor;
183
    
191
    
184
    // This is the default access type for the class accessor of this 
192
    // This is the default access type for the class accessor of this 
185
    // descriptor. The default access type is needed for those embeddables and 
193
    // descriptor. The default access type is needed for those embeddables and 
Lines 689-713 Link Here
689
     public MetadataAccessor getBiDirectionalManyToManyAccessor(String className, String attributeName) {
697
     public MetadataAccessor getBiDirectionalManyToManyAccessor(String className, String attributeName) {
690
        return m_biDirectionalManyToManyAccessors.get(className).get(attributeName);
698
        return m_biDirectionalManyToManyAccessors.get(className).get(attributeName);
691
    }
699
    }
692
    
693
    /**
694
     * INTERNAL:
695
     * This will return the attribute names for all the direct to field mappings 
696
     * on this descriptor metadata. This method will typically be called when an 
697
     * embedded or embedded id attribute has been specified as an order by 
698
     * field
699
     */
700
    public List<String> getOrderByAttributeNames() {
701
        if (m_orderByAttributeNames.isEmpty()) {
702
            for (DatabaseMapping mapping : getMappings()) {
703
                if (mapping.isDirectToFieldMapping()) {
704
                    m_orderByAttributeNames.add(mapping.getAttributeName());
705
                }
706
            }
707
        }
708
        
709
        return m_orderByAttributeNames;
710
    }
711
700
712
    /**
701
    /**
713
     * INTERNAL:
702
     * INTERNAL:
Lines 840-845 Link Here
840
    /**
829
    /**
841
     * INTERNAL:
830
     * INTERNAL:
842
     */
831
     */
832
    public MetadataDescriptor getMetamodelMappedSuperclassChildDescriptor() {
833
        return m_metamodelMappedSuperclassChildDescriptor;
834
    }
835
    
836
    /**
837
     * INTERNAL:
838
     * This will return the attribute names for all the direct to field mappings 
839
     * on this descriptor metadata. This method will typically be called when an 
840
     * embedded or embedded id attribute has been specified as an order by 
841
     * field
842
     */
843
    public List<String> getOrderByAttributeNames() {
844
        if (m_orderByAttributeNames.isEmpty()) {
845
            for (DatabaseMapping mapping : getMappings()) {
846
                if (mapping.isDirectToFieldMapping()) {
847
                    m_orderByAttributeNames.add(mapping.getAttributeName());
848
                }
849
            }
850
        }
851
        
852
        return m_orderByAttributeNames;
853
    }
854
    
855
    /**
856
     * INTERNAL:
857
     */
843
    public MetadataClass getPKClass(){
858
    public MetadataClass getPKClass(){
844
        return m_pkClass;
859
        return m_pkClass;
845
    }
860
    }
Lines 847-852 Link Here
847
    /**
862
    /**
848
     * INTERNAL:
863
     * INTERNAL:
849
     */
864
     */
865
    public Map<String, String> getPKClassIDs() {
866
        return m_pkClassIDs;
867
    }
868
    
869
    /**
870
     * INTERNAL:
871
     */
850
    public String getPKClassName() {
872
    public String getPKClassName() {
851
        String pkClassName = null;
873
        String pkClassName = null;
852
        
874
        
Lines 867-879 Link Here
867
    
889
    
868
    /**
890
    /**
869
     * INTERNAL:
891
     * INTERNAL:
870
     */
871
    public Map<String, String> getPKClassIDs() {
872
        return m_pkClassIDs;
873
    }
874
    
875
    /**
876
     * INTERNAL:
877
     * Method to return the primary key field name this descriptor metadata. 
892
     * Method to return the primary key field name this descriptor metadata. 
878
     * It assumes there is one.
893
     * It assumes there is one.
879
     */
894
     */
Lines 1604-1609 Link Here
1604
    /**
1619
    /**
1605
     * INTERNAL:
1620
     * INTERNAL:
1606
     */
1621
     */
1622
    public void setMetamodelMappedSuperclassChildDescriptor(MetadataDescriptor childDescriptor) {
1623
        m_metamodelMappedSuperclassChildDescriptor = childDescriptor;
1624
    }
1625
    
1626
    /**
1627
     * INTERNAL:
1628
     */
1607
    public void setOptimisticLockingPolicy(OptimisticLockingPolicy policy) {
1629
    public void setOptimisticLockingPolicy(OptimisticLockingPolicy policy) {
1608
        m_descriptor.setOptimisticLockingPolicy(policy);
1630
        m_descriptor.setOptimisticLockingPolicy(policy);
1609
    }
1631
    }
(-)jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/metadata/MetadataProject.java (-10 / +16 lines)
Lines 61-66 Link Here
61
 *       - 317708: Exception thrown when using LAZY fetch on VIRTUAL mapping
61
 *       - 317708: Exception thrown when using LAZY fetch on VIRTUAL mapping
62
 *     07/23/2010-2.2 Guy Pelletier 
62
 *     07/23/2010-2.2 Guy Pelletier 
63
 *       - 237902: DDL GEN doesn't qualify SEQUENCE table with persistence unit schema
63
 *       - 237902: DDL GEN doesn't qualify SEQUENCE table with persistence unit schema
64
 *     08/11/2010-2.2 Guy Pelletier 
65
 *       - 312123: JPA: Validation error during Id processing on parameterized generic OneToOne Entity relationship from MappedSuperclass
64
 ******************************************************************************/  
66
 ******************************************************************************/  
65
package org.eclipse.persistence.internal.jpa.metadata;
67
package org.eclipse.persistence.internal.jpa.metadata;
66
68
Lines 472-489 Link Here
472
     *  This method is referenced by EntityAccessor.addPotentialMappedSuperclass()
474
     *  This method is referenced by EntityAccessor.addPotentialMappedSuperclass()
473
     *  during an initial predeploy() and later during a deploy()
475
     *  during an initial predeploy() and later during a deploy()
474
     *  </p>
476
     *  </p>
475
     * @param metadataClass - the wrapped java class that the MappedSuperclass represents
476
     * @param accessor - The mappedSuperclass accessor for the field on the mappedSuperclass<p>
477
     * @param accessor - The mappedSuperclass accessor for the field on the mappedSuperclass<p>
477
     * @since EclipseLink 1.2 for the JPA 2.0 Reference Implementation
478
     * @since EclipseLink 1.2 for the JPA 2.0 Reference Implementation
478
     */    
479
     */    
479
    public void addMetamodelMappedSuperclass(MetadataClass metadataClass, MappedSuperclassAccessor accessor) {
480
    public void addMetamodelMappedSuperclass(MappedSuperclassAccessor accessor, MetadataDescriptor childDescriptor) {
480
        // If metadataClass is null, then get it from the location on the accessor
481
        // Check for an existing entry before proceeding. Metamodel mapped 
481
        String className = metadataClass.getName();
482
        // superclasses need only (and should only) be added once. This code 
482
        
483
        // will be called from every entity that inherits from it. There is no
483
        // check for an existing entry before proceeding - as a Map.put() will replace the existing accessor
484
        // need to check for className == null here as the mapped superclass
484
        // this code is run first through predeploy() and second through deploy()
485
        // accessor is always created with a class.
485
        if (null != className && ! m_metamodelMappedSuperclasses.containsKey(className)) {
486
        if (! m_metamodelMappedSuperclasses.containsKey(accessor.getJavaClassName())) {
486
            MetadataDescriptor metadataDescriptor = accessor.getDescriptor();
487
            MetadataDescriptor metadataDescriptor = accessor.getDescriptor();
488
                       
489
            // Set a child entity descriptor on the mapped superclass descriptor.
490
            // This descriptor (and its mapping accessors) will help to resolve
491
            // any generic mapping accessors from the mapped superclass.
492
            metadataDescriptor.setMetamodelMappedSuperclassChildDescriptor(childDescriptor);
487
            
493
            
488
            // Note: set the back pointer from the MetadataDescriptor back to its' accessor manually before we add accessors
494
            // Note: set the back pointer from the MetadataDescriptor back to its' accessor manually before we add accessors
489
            metadataDescriptor.setClassAccessor(accessor);
495
            metadataDescriptor.setClassAccessor(accessor);
Lines 499-505 Link Here
499
            accessor.addAccessors();
505
            accessor.addAccessors();
500
            
506
            
501
            // Add the accessor to our custom Map keyed on className for separate processing in stage2
507
            // Add the accessor to our custom Map keyed on className for separate processing in stage2
502
            m_metamodelMappedSuperclasses.put(className, accessor);
508
            m_metamodelMappedSuperclasses.put(accessor.getJavaClassName(), accessor);
503
            
509
            
504
            // Note: The classDescriptor is always a RelationalDescriptor instance - a cast is safe here unless setDescriptor() sets it to XMLDescriptor or EISDescriptor
510
            // Note: The classDescriptor is always a RelationalDescriptor instance - a cast is safe here unless setDescriptor() sets it to XMLDescriptor or EISDescriptor
505
            RelationalDescriptor relationalDescriptor = (RelationalDescriptor)metadataDescriptor.getClassDescriptor();
511
            RelationalDescriptor relationalDescriptor = (RelationalDescriptor)metadataDescriptor.getClassDescriptor();
Lines 530-536 Link Here
530
             * but we do not need it until metamodel processing time avoiding a _persistence_new call.
536
             * but we do not need it until metamodel processing time avoiding a _persistence_new call.
531
             * See MetamodelImpl.initialize()
537
             * See MetamodelImpl.initialize()
532
             */
538
             */
533
            m_session.getProject().addMappedSuperclass(metadataClass, relationalDescriptor);
539
            m_session.getProject().addMappedSuperclass(accessor.getJavaClass(), relationalDescriptor);
534
        }
540
        }
535
    }
541
    }
536
    
542
    

Return to bug 312132