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