MYSQL
JAVA EE 6
JPA 2
Hallo,
ich möchte aus einer DB "Video-Objekte" absteigend
- danach wie oft bzw. wie gut sie gevotet(RATING) worden sind - holen.
VideoRatingEntity
@ManyToOne()
@JoinColumn(name = "VIDEO_ID")
videoEntity
ID | VIDEO_ID| USER_ID| RATING
--------------------------------
Video Entity
@OneToMany
videoRatingEntities
ID | ... | ... |
-------------
Mein Ansatz:
"SELECT v, sum(vrr) "
+ " FROM VideoEntity AS v"
+ " JOIN v.videoRatingEntities AS vr"
+ " JOIN vr.rating AS vrr"
+ " GROUP BY v"
+ " ORDER BY sum(vrr) DESC";
EXCEPTION:
SCHWERWIEGEND: java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager:
Exception Description: Syntax error parsing the query [SELECT v, sum(vrr) FROM VideoEntity AS v JOIN v.videoRatingEntities AS vr JOIN vr.rating AS vrr GROUP BY v ORDER BY sum(vrr) DESC].
Internal Exception: org.eclipse.persistence.internal.libraries.antlr.runtime.EarlyExitException
Hoffe jemand kann weiterhelfen.
JAVA EE 6
JPA 2
Hallo,
ich möchte aus einer DB "Video-Objekte" absteigend
- danach wie oft bzw. wie gut sie gevotet(RATING) worden sind - holen.
VideoRatingEntity
@ManyToOne()
@JoinColumn(name = "VIDEO_ID")
videoEntity
ID | VIDEO_ID| USER_ID| RATING
--------------------------------
Video Entity
@OneToMany
videoRatingEntities
ID | ... | ... |
-------------
Mein Ansatz:
"SELECT v, sum(vrr) "
+ " FROM VideoEntity AS v"
+ " JOIN v.videoRatingEntities AS vr"
+ " JOIN vr.rating AS vrr"
+ " GROUP BY v"
+ " ORDER BY sum(vrr) DESC";
EXCEPTION:
SCHWERWIEGEND: java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager:
Exception Description: Syntax error parsing the query [SELECT v, sum(vrr) FROM VideoEntity AS v JOIN v.videoRatingEntities AS vr JOIN vr.rating AS vrr GROUP BY v ORDER BY sum(vrr) DESC].
Internal Exception: org.eclipse.persistence.internal.libraries.antlr.runtime.EarlyExitException
Hoffe jemand kann weiterhelfen.
Zuletzt bearbeitet: