Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Unacceptable named queries after upgrade from 1.0.2

Hi Tom

I tried what you suggested: Removing @Basic and @Column annotations gave the same result. I don't have orm.xml, no. There is only one Recording on classpath (double-checked).

A new clue is that if I remove static weaving then the problem disappears. (This is a JSE app)

Any more thoughts?

Many thanks
Brad


On 2/3/10 3:28 AM, Tom Ware wrote:
Hi Brad,

You are getting this issue because of the mappings in your Recording object, not because of the JPQL you are writing.

For some reason the mapping to "id" is not recognized, but I am not certain what the reason is. I would start debugging by playing around with that mapping.

     @Id
     @GeneratedValue(strategy = GenerationType.IDENTITY)
     @Basic(optional = false)
     @Column(name = "id", updatable = false)
     private Integer id;

Does removing the @Basic annotation help? How about the @Column annotation. Do you have Orm.xml? Is there any chance another version of Recording is somewhere on the classpath?

-Tom

Brad Milne wrote:
I am investigating upgrading our system from 1.0.2 to 2.0.1. I have come across the whole getResultList as List<Object[]> instead of the old List<List<Object>> deal. The issue I now have is where named queries are failing, for example: @NamedQuery(name = "Recording.findById", query = "SELECT r FROM Recording r WHERE r.id = :id")

/Target Invocation Exception: Exception [EclipseLink-8030] (Eclipse Persistence Services - 2.0.1.v20100213-r6600): org.eclipse.persistence.exceptions.JPQLException Exception Description: Error compiling the query [Recording.findById: SELECT r FROM Recording r WHERE r.id = :id], line 1, column 37: unknown state or association field [id] of class [xxx.entities.Recording]. Descriptor: RelationalDescriptor(xxx.entities.Recording --> [DatabaseTable(recordings)])
/
This is the most basic of my named queries and it still happens. Again, this all worked fine in 1.0.2.

I don't get problems if I pare it back to:
[Recording.findAll: SELECT r FROM Recording r]

But do with:
[Recording.findAll: SELECT r FROM Recording r ORDER BY r.id]

It seems it doesn't want to recognise my fields. Interestingly it doesn't seem to be happening with any of my other entities. This one is defined about the middle of my persistence.xml file, so it's not the first one hit. Here's relevant sections of the Recording class, also showing most of the NamedQueries commented out as I try to sort this out:

@Entity
@Table(name = "recordings")
@NamedQueries( { @NamedQuery(name = "Recording.findAll", query = "SELECT r FROM Recording r ORDER BY r.id")
// @NamedQuery(name = "Recording.findById", query =
// "SELECT r FROM Recording r WHERE r.id = :id"),
// @NamedQuery(name = "Recording.findByListened", query =
// "SELECT r FROM Recording r WHERE r.listened = :listened ORDER BY r.date, r.time"),
// @NamedQuery(name = "Recording.findForDate", query =
// "SELECT r FROM Recording r WHERE r.date = :date ORDER BY r.date, r.time"),
// @NamedQuery(name = "Recording.findForDateRange", query =
// "SELECT r FROM Recording r WHERE r.date BETWEEN :date AND :toDate ORDER BY r.date, r.time"),
// @NamedQuery(name = "Recording.findForDateWhereUnlistened", query =
// "SELECT r FROM Recording r WHERE r.date = :date and r.listened = false ORDER BY r.date, r.time"), // @NamedQuery(name = "Recording.findForDateRangeWhereUnlistened", query = // "SELECT r FROM Recording r WHERE r.'date BETWEEN :date AND :toDate and r.listened = false ORDER BY r.date, r.time"),
// @NamedQuery(name = "Recording.findForDateWithEvent", query =
// "SELECT r FROM Recording r WHERE r.date = :date and r.event is not null ORDER BY r.date, r.time"),
// @NamedQuery(name = "Recording.findUnlistened", query =
// "SELECT r FROM Recording r WHERE r.listened = false ORDER BY r.date, r.time"),
// @NamedQuery(name = "Recording.findOldestUnlistenedDate", query =
// "SELECT r.date FROM Recording r WHERE r.listened = false ORDER BY r.date, r.time")
})
public class Recording implements Serializable {

private static final DateFormat TIME_FORMAT = new SimpleDateFormat("HH:mm:ss"); private static final DateFormat DATE_FORMAT = DateFormat.getDateInstance(DateFormat.SHORT);

    public enum RecordingFilter {
        ALL, UNLISTENED, WITH_EVENT;
    }

    private static DayNightDecider dayNightDecider;

    @Transient
private final PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id", updatable = false)
    private Integer id;

    @Basic(optional = false)
    @Column(name = "time", updatable = false)
    @Temporal(TemporalType.TIME)
    private Date time;

    @Basic(optional = false)
    @Column(name = "date", updatable = false)
    @Temporal(TemporalType.DATE)
    private Date date;

    @Lob
    @Basic(fetch = FetchType.LAZY)
    @Column(name = "recording", updatable = false)
    private byte[] recording;

    @Basic(optional = false)
    @Column(name = "listened")
    private boolean listened;

    @Basic(optional = false)
    @Column(name = "format_id", updatable = false)
    private int formatId;

    @Basic
    @Column(name = "comment")
    private String comment;

    @OneToOne(mappedBy = "recording", cascade = CascadeType.ALL)
    private Event event;

    @Transient
    private Boolean night;


Thanks in advance
Brad


------------------------------------------------------------------------

_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users



Back to the top