上記のように、私は上記の例外を取得しています。
手伝ってもらえますか?ありがとう
私はさまざまなガイド/チュートリアルを見てきましたが、そのような例を実行するために必要なマッピングが何であるかを実際には教えてくれません。または私が見た例には、データの取得を伴うものは実際には何もありません。それは主に挿入/更新と削除についてです。
jbossドキュメントの例(http://docs.jboss.org/hibernate/orm/4.1/manual/en-US/html/ch16.html)
select foo
from Foo foo, Bar bar
where foo.startDate = bar.date
これは私のHQLです:
sessionFactory.getCurrentSession().createQuery("from Staff staff, Url url where (staff.id = url.id (+))");
これは私のマッピングXMLです
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="org.flinders.staffdirectory.models.database.Staff" table="teld_summary">
<id name="id" column="telsumm_id" type="string" />
<property name="title" column="telsumm_name_title" type="string" />
<property name="firstname" column="telsumm_preferred_name" type="string" />
<property name="surname" column="telsumm_surname" type="string" />
<one-to-one name="url" class="org.flinders.staffdirectory.models.database.Url" />
</class>
<class name="org.flinders.staffdirectory.models.database.Url" table="teld_urls">
<id name="id" column="telurl_id">
<generator class="foreign">
<param name="property">staff</param>
</generator>
</id>
<one-to-one name="staff" class="org.flinders.staffdirectory.models.database.Staff" constrained="true" />
<property name="url" column="url" />
</class>
</hibernate-mapping>
私のエラー
org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: ) near line 1, column 142 [from org.flinders.staffdirectory.models.database.Staff staff, org.flinders.staffdirectory.models.database.Url url where (staff.id = url.id (+)) and (staff.surnameSearch like 'A%') order by surname, firstname]
org.hibernate.hql.internal.ast.QuerySyntaxException.convert(QuerySyntaxException.java:54)
org.hibernate.hql.internal.ast.QuerySyntaxException.convert(QuerySyntaxException.java:47)
org.hibernate.hql.internal.ast.ErrorCounter.throwQueryException(ErrorCounter.java:79)
org.hibernate.hql.internal.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:276)
org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:180)
org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:136)
org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:105)
org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:80)
org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:168)
org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:221)
org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:199)
org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1735)
org.flinders.staffdirectory.dao.StaffDAOImpl.searchForStaff(StaffDAOImpl.java:49)
org.flinders.staffdirectory.services.SearchServiceImpl.searchForStaff(SearchServiceImpl.java:26)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:601)
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:319)
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
$Proxy13.searchForStaff(Unknown Source)
org.flinders.staffdirectory.controllers.SearchController.showSearchResults(SearchController.java:33)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:601)
org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:219)
org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:100)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:604)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:565)
org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
私のスタッフクラス
package org.flinders.staffdirectory.models.database;
import java.util.Date;
import org.flinders.staffdirectory.models.database.Url;
public class Staff {
private String id;
private String title;
private String firstname;
private String surname;
private Url url;
public String getId() {
return id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getFirstname() {
return firstname;
}
public void setFirstname(String firstname) {
this.firstname = firstname;
}
public String getSurname() {
return surname;
}
public void setSurname(String surname) {
this.surname = surname;
}
public Url getUrl() {
return url;
}
public void setUrl(Url url) {
this.url = url;
}
}
私のURLクラス
package org.flinders.staffdirectory.models.database;
import org.flinders.staffdirectory.models.database.Staff;
public class Url {
private String id;
private String url;
private Staff staff;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public Staff getStaff() {
return staff;
}
public void setStaff(Staff staff) {
this.staff = staff;
}
}