问题描述
我正在尝试修复Java 6中用于过滤和列出客户生日日期的应用程序。我在pgadmin上测试了Query并使其正常工作,但是当我将其添加到HQL并运行时,出现以下错误:
java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected end of subtree [FROM br.com.chart.beans.Clientes as c WHERE (c.situacao = 'A' OR c.situacao IS NULL) AND (c.sexo = 'M' OR c.sexo IS NULL) AND (select extract (doy from c.datanasc )) between (select extract (doy from '2020-09-14 00:00:00')) and (select extract (doy from '2020-09-16 23:59:59')) ORDER BY c.nome]
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:131)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:155)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:162)
at org.hibernate.internal.AbstractSharedSessionContract.createquery(AbstractSharedSessionContract.java:663)
at org.hibernate.internal.AbstractSharedSessionContract.createquery(AbstractSharedSessionContract.java:102)
at br.com.chart.persistence.genericdao.GenericDAOImpl.findByHQL(GenericDAOImpl.java:820)
at sun.reflect.GeneratedMethodAccessor1583.invoke(UnkNown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
实体客户:
@Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED)
@Getter @Setter
public class Clientes implements Serializable,Loggable {
private static final long serialVersionUID = 1L;
private int clcodigo;
private Empresas multiEmpresa;
.
.
.
private Date datanasc;
.
.
.
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + clcodigo;
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Clientes other = (Clientes) obj;
if (clcodigo != other.clcodigo)
return false;
return true;
}
}
SimpleDateFormat sdf = new SimpleDateFormat("YYYY-MM-dd HH:mm:ss");
if (this.nascimento) {
this.aniversarioInicio = CalendarUtils.resetTime(this.aniversarioInicio);
this.aniversarioFinal = CalendarUtils.getDate235959(this.aniversarioFinal);
restrictions.add("(select extract (doy from c.datanasc )) between (select extract (doy from '"+sdf.format(this.aniversarioInicio)+"')) and (select extract (doy from '"+sdf.format(this.aniversarioFinal)+"')) ");
非常感谢您!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)