i am trying to query two database tables using a result class with the following query:
public List<UserStatus> getUserStatus(String username) {
String qlString =
"SELECT NEW no.uia.slit.ejb.UserStatus(file.filename, file.uploadTime, mod.title, mod.dueAt) "
+ "FROM DownloadableFile file, Module mod"
+ "where file.moduleId = mod.id";
TypedQuery<UserStatus> query = em.createQuery(qlString, UserStatus.class);
return query.getResultList();
}
Running this i get the following error:
Caused by: <openjpa-2.3.0-nonfinal-1540826-r422266:1542644 nonfatal user error> org.apache.openjpa.persistence.ArgumentException: Encountered "mod ." at character 71, but expected: ["(", "+", "-", ":", "?", "ABS", "AVG", "CASE", "COALESCE", "CONCAT", "COUNT", "CURRENT_DATE", "CURRENT_TIME", "CURRENT_TIMESTAMP", "ENTRY", "INDEX", "KEY", "LENGTH", "LOCATE", "LOWER", "MAX", "MIN", "MOD", "NULLIF", "SIZE", "SQRT", "SUBSTRING", "SUM", "TRIM", "TYPE", "UPPER", "VALUE", <BOOLEAN_LITERAL>, <DATE_LITERAL>, <DECIMAL_LITERAL>, <IDENTIFIER>, <INTEGER_LITERAL>, <STRING_LITERAL2>, <STRING_LITERAL>, <TIMESTAMP_LITERAL>, <TIME_LITERAL>].
My result class is as follows:
public class UserStatus {
private String title;
private Date dueAt;
private String filename;
private Timestamp uploadTime;
public UserStatus(){
super();
}
public UserStatus(String filename, Timestamp uploadTime, String title, Date dueAt) {
this.filename = filename;
this.uploadTime = uploadTime;
this.title = title;
this.dueAt = dueAt;
}
public void setTitle(String title) {
this.title = title;
}
public String getTitle() {
return title;
}
public void setDueAt(Date dueAt) {
this.dueAt = dueAt;
}
public Date getDueAt() {
return dueAt;
}
public void setFileName(String filename) {
this.filename = filename;
}
public String getFileName() {
return filename;
}
public void setUploadTime(Timestamp uploadTime) {
this.uploadTime = uploadTime;
}
public Timestamp getUploadTime() {
return uploadTime;
}
}
i used an example i found to make the query and i cant figure out what is wrong, i know it says "mod . " is wrong but why.
edit: https://blogs.oracle.com/adf/entry/ejb_dc_using_jpql_constructor this is the example i used.