This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 172943 - error flagged in editor for valid Map<,> mapping
Summary: error flagged in editor for valid Map<,> mapping
Status: RESOLVED FIXED
Alias: None
Product: javaee
Classification: Unclassified
Component: Persistence (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Sergey Petrov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-09-23 20:31 UTC by err
Modified: 2009-11-06 09:57 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
popup error but good compile (30.47 KB, image/png)
2009-09-23 20:32 UTC, err
Details
project with problem (457.17 KB, text/plain)
2009-10-30 16:30 UTC, err
Details

Note You need to log in before you can comment on or make changes to this bug.
Description err 2009-09-23 20:31:04 UTC
Look at the attached .png. It shows both the error displayed and the log of the successful compile. Project is
AstroPersist. AspectdisplayData is serializable. I am changing a map mapping so the value is a column rather than its
Entity. The error showed up when I added the @ElementCollection annotation.

This is what I what it used to be

    //@OneToMany
    //@JoinTable(name = "ASPECTDISPLAY",
    //    joinColumns = {@JoinColumn(name = "CHART_ID",
    //                           referencedColumnName = "ID", nullable = false)})
    //@MapKeyJoinColumn(name = "EVENT_ID", nullable=false)
    //private Map<Event, Aspectdisplay> aspectdisplayMap;

This is what I'm converting to (not complete)
    // VALUE IS OBJECT RATHER THAN ENTITY
    @ElementCollection(targetClass = AspectdisplayData.class)
    @CollectionTable
    @MapKeyJoinColumn(name = "EVENT_ID", nullable=false)
    private Map<Event, AspectdisplayData> aspectdisplayDataMap;
Comment 1 err 2009-09-23 20:32:48 UTC
Created attachment 88235 [details]
popup error but good compile
Comment 2 Sergey Petrov 2009-09-23 21:02:24 UTC
yes, it's valid java class and should be compilable, but it's not valid entity class and may fail to works correctly,
all details are in tooltip. what behavior do you expect? in my opinion it's not an issue.
Comment 3 err 2009-09-23 22:35:20 UTC
> it's not valid entity class ... all details are in tooltip.
But its looking for a "Basic attribute" as it says in the tooltip not an entity, and AspectDisplayData is serializable.

In the spec
    2.7.2 Map Values
        When the value type of the map is a basic type or an embeddable class, a collection table is used to map
        the map. If Java generic types are not used, the ElementCollection annotation must specify the
        value type for the map. The default column mappings for the map value are derived according to the
        default mapping rules for the CollectionTable annotation

The error flags started showing up as soon as I added the "@ElementCollection annotation.

This is what I think is the correct mapping (but there still an SQL issue from eclipselink, but eclipselink isn't done
with the Map<key,val> relations). This is very similar to example 2 in section 11.1.31 MapKeyJoinColumn Annotation.
    @ElementCollection //(targetClass = AspectdisplayData.class)
    @Column(name="DAT")
    @CollectionTable(name = "ASPECTDISPLAY")
    @MapKeyJoinColumn(name = "EVENT_ID", nullable=false)
    private Map<Event, AspectdisplayData> aspectdisplayDataMap;
Comment 4 Sergey Petrov 2009-09-24 05:47:00 UTC
ok, need to reevaluate, but it's not "error but compiles issue" then.
Comment 5 err 2009-09-24 05:57:36 UTC
> not "error but compiles issue"
hope changed summary makes more sense
Comment 6 Sergey Petrov 2009-09-28 12:13:28 UTC
may be similar to issue 167419
Comment 7 err 2009-10-20 17:07:42 UTC
The eclipselink issues are resolved and now I'm able to use @ElementCollection. I put the "TargetMilestone" back to TDB
since it was initially set to "next" when you thought it "may fail to works correctly" (and the related issue 167419 was
marked "next" on 6.7). It is difficult to work with a file that has error markings (a psychological issue I guess).

Here is a more complete example; it executes correctly (good SQL) with eclipselink M10 (possibly works with earlier
release).

@Entity
@Table(name = "CHART", catalog = "", schema = "ERNIE")
public class Chart implements Serializable {
    private static final long serialVersionUID = 1L;
    ...
    @ElementCollection
    @CollectionTable(name="ASPECTDISPLAY", schema = "ERNIE",
        joinColumns=@JoinColumn(name="CHART_ID"))
    @MapKeyJoinColumns(
        @MapKeyJoinColumn(name = "EVENT_ID", nullable=false, updatable=false))
    private Map<Event, Aspectdisplay> aspectdisplayMap;
                                      ~~~~~~~~~~~~~~~~ NOT REALLY AN ERROR


@Embeddable
public class Aspectdisplay implements Serializable {
    private static final long serialVersionUID = 1L;
    @Basic(optional = false)
    @Lob
    @Column(name = "DAT", nullable = false)
    private AspectdisplayData dat;
Comment 8 Sergey Petrov 2009-10-30 14:01:33 UTC
can you provide complete code?
Comment 9 err 2009-10-30 16:30:35 UTC
Created attachment 90321 [details]
project with problem
Comment 10 err 2009-10-30 16:35:20 UTC
Attached zip file with project. Chart.java is the file with the @ElementCollection.
Comment 11 Sergey Petrov 2009-11-03 13:23:46 UTC
thanks, will look now.
Comment 12 Sergey Petrov 2009-11-05 12:13:41 UTC
error will not be shown now
http://hg.netbeans.org/web-main/rev/0d2f5cbcce03

but this area still have an issue, verification of attribtes with ElementCollection isn't supported yet, may need to be
filed as new issue and can be addressed in next release only as it requires new hint messages.
Comment 13 Quality Engineering 2009-11-06 09:57:53 UTC
Integrated into 'main-golden', will be available in build *200911060201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/0d2f5cbcce03
User: sergeyp@netbeans.org
Log: fix #172943 - if element is marked with ElementCollection annotation no error will be shown based on attrinbute type, need to add proper verification of ElementCollection attributes in next realease