Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 328774

Summary: TABLE_PER_CLASS-mapped key of a java.util.Map does not work for querying
Product: z_Archived Reporter: Frank Schwarz <fs5>
Component: EclipselinkAssignee: Nobody - feel free to take it <nobody>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: eclipselink.orm-inbox, guy.pelletier, tom.ware
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard: table_per_class submitted_patch
Attachments:
Description Flags
full stacktrace
none
reproducer
none
proposed patch
peter.krogh: iplog+
Final patch (includes model and testing with core fix)
none
Final patch (includes model and testing with core fix) guy.pelletier: iplog+

Description Frank Schwarz CLA 2010-10-26 16:28:42 EDT
Build Identifier: Trunk

@Entity
public class DesignPattern {
  @ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
  private Map<ProgrammingLanguage, CodeExample> codeExamples = new HashMap<ProgrammingLanguage, CodeExample>();
}


@Entity
public class CodeExample extends BaseEntity { }


@Entity @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public abstract class BaseEntity { }



A simple query "SELECT x FROM DesignPattern x" causes:

[EL Warning]: Exception [EclipseLink-6157] (Eclipse Persistence Services - @VERSION@.@QUALIFIER@): org.eclipse.persistence.exceptions.QueryException
Exception Description: Element [user.test.model.CodeExample@879860] is being added to a map without a key.  This generally means the database does not hold a key that is expected.
Query: ReadAllQuery(name="codeExamples" referenceClass=CodeExample sql="SELECT t1.ID, t1.CONTENT, t0.codeExamples_KEY FROM DESIGNPATTERN_CODEEXAMPLE t0, CODEEXAMPLE t1 WHERE ((t0.DesignPattern_ID = ?) AND (t1.ID = t0.codeExamples_ID))")


Reproducible: Always
Comment 1 Frank Schwarz CLA 2010-10-26 16:30:58 EDT
Created attachment 181776 [details]
full stacktrace
Comment 2 Frank Schwarz CLA 2010-10-26 16:33:41 EDT
Created attachment 181777 [details]
reproducer
Comment 3 Frank Schwarz CLA 2010-10-26 16:36:55 EDT
Created attachment 181778 [details]
proposed patch
Comment 4 Tom Ware CLA 2010-11-12 08:20:42 EST
Setting target and priority.  See the following page for the meanings of these fields:

http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines
Comment 5 Guy Pelletier CLA 2010-11-24 09:40:11 EST
Created attachment 183762 [details]
Final patch (includes model and testing with core fix)
Comment 6 Guy Pelletier CLA 2010-11-24 09:52:33 EST
Created attachment 183768 [details]
Final patch (includes model and testing with core fix)
Comment 7 Guy Pelletier CLA 2010-11-24 09:56:51 EST
Patch submitted.

Reviewed by: Guy Pelletier, Tom Ware
Comment 8 Eclipse Webmaster CLA 2022-06-09 10:15:49 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink
Comment 9 Eclipse Webmaster CLA 2022-06-09 10:35:24 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink