我得到了获取两个表数据的查询
我正在尝试在与hibernate3一起工作的java程序中使用它。每次我试图获取数据时,都会遇到异常。我的完整代码是在coderanch的问题,第一次答复有完整的java,xml文件。。
这里是我在java程序中使用的查询
String selectQuery = "select student.roll_no, student.name, exam_dates.subject, exam_dates.date "
+ "from student student "
+ "JOIN exam_dates exam_dates on exam_dates.roll_no = student.roll_no";
还有一个要审判
String selectQuery = "select student.roll_no, student.name, exam_dates.subject, exam_dates.date "
+ "from student student "
+ "INNER JOIN exam_dates exam_dates on exam_dates.roll_no = student.roll_no";
通过使用它,我得到异常作为follows:-
14:19:07,752 INFO MemoryContextFactory:34 - Creating EJB3Unit initial JNDI context
org.hibernate.QueryException: outer or full join must be followed by path expression [select student.roll_no, student.name, exam_dates.subject, exam_dates.date from student student INNER JOIN exam_dates exam_dates on exam_dates.roll_no = student.roll_no]
at org.hibernate.hql.classic.FromParser.token(FromParser.java:170)
at org.hibernate.hql.classic.ClauseParser.token(ClauseParser.java:86)
at org.hibernate.hql.classic.PreprocessingParser.token(PreprocessingParser.java:108)
at org.hibernate.hql.classic.ParserHelper.parse(ParserHelper.java:28)
at org.hibernate.hql.classic.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:216)
at org.hibernate.hql.classic.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:185)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623)
at test_db.get_table_by_join(test_db.java:99)
at test_db$1.run(test_db.java:40)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
有人能帮我吗?
1条答案
按热度按时间yyyllmsg1#
将实体类创建为
examdates是另一个Map到考试日期表的类。你什么时候打电话
它会给你student对象,然后调用s.getexamdates,它会给你考试日期