Guys, I have the following problem:
I'd like to do a Query with a JOIN over 2 Tables.
When I perform the query with the HSQL Database Manager, everything works fine:
Code:
SELECT * FROM kunde k JOIN ticketcard t ON t.kartennr = k.kartennr WHERE t.vname LIKE 'Morgan' AND t.nname LIKE 'Breitfuss' AND k.kartennr = 8;
But if I try the same query in my own Java code, the only thing I get is the following Unexpected Token Exception. :cry:
Code:
Session session = HibernateSessionFactory.currentSession();
//List vlist = session.find("FROM Veranstaltung WHERE Dauer >= 112 ORDER BY Dauer ASC");
session.find("SELECT * FROM kunde JOIN ticketcard ON ticketcard.kartennr = kunde.kartennr WHERE ticketcard.vname LIKE 'Morgan' AND ticketcard.nname LIKE 'Breitfuss' AND kunde.kartennr = 8");
Code:
java.lang.RuntimeException: unexpected token: join [SELECT * FROM kunde JOIN ticketcard ON ticketcard.kartennr = kunde.kartennr WHERE ticketcard.vname LIKE 'Morgan' AND ticketcard.nname LIKE 'Breitfuss' AND kunde.kartennr = 8]
at ticketline.WebAccount$1.widgetSelected(WebAccount.java:153)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:89)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:842)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2908)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2541)
at ticketline.MainApp1.open(MainApp1.java:736)
at ticketline.MainApp1.runMain(MainApp1.java:103)
at ticketline.Login1$2.widgetSelected(Login1.java:139)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:89)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:842)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2908)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2541)
at ticketline.Login1.open(Login1.java:216)
at ticketline.Login1.main(Login1.java:61)
Can someone explain what I did wrong? I don't see any fault in my code ...
------------------
Hibernate version: 2