1
List<Users> temp2;
temp2 = em.createQuery("SELECT u FROM Users u "
+ "NATURAL LEFT JOIN CourseMembers b "
+ "WHERE b.courseMembersPK.userID IS NULL").getResultList();
嗨!如果在另一個表中沒有記錄(CourseMembers
),我試圖獲取所有用戶對象。你可以在JPA SQL javaEE中做自然左連接嗎?
但我從我的EJB
收到此錯誤:
Caused by: Exception [EclipseLink-0] (Eclipse Persistence Services - 2.6.2.qualifier): org.eclipse.persistence.exceptions.JPQLException
Exception Description: Syntax error parsing [SELECT u FROM Users u NATURAL LEFT JOIN CourseMembers b WHERE b.courseMembersPK.userID IS NULL].
[21, 22] The FROM clause has 'Users u' and 'NATURAL LEFT JOIN CourseMembers b' that are not separated by a comma.
[30, 30] An identification variable must be provided for a range variable declaration.
我試圖用逗號,但它給了我另一個錯誤。我該如何解決這個問題?
在此查詢語言中,您必須使用對象結構。 – Jens
所以你不允許使用join? –
你可以使用連接。但不自然加入 – Jens