queryDSL如何与接口一起工作?

编程入门 行业动态 更新时间:2024-10-24 14:18:41
本文介绍了queryDSL如何与接口一起工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一组实现相同接口的类.例如:

I have a set of classes that implements the same interface. For example:

public interface Employee{ private String name; public void work(); public String getName(); } @PersistenceCapable(detachable = "true") public class Accountant implements Employee{ } @PersistenceCapable(detachable = "true") public class Secretary implements Employee{ }

另一个包含Employee实现的类:

And another class that holds the Employee implementations:

public class Department{ private ArrayList<Employee> employees; public ArrayList<Employee> getEmployees(); }

我想获取一个名为"Mary"的雇员的部门列表.我应该如何放置我的jdo查询?我是否在Employee界面上缺少注释?

I want to get a list of Department that has Employee named "Mary". How should I put my jdo query? Am I missing some annotation to the interface Employee?

我怀疑生成的Q类不正确.我有

I suspect the Q class generated is not correct. I got

public final SimplePath<java.util.ArrayList<Employee>>

在生成的Q类中的

.是不是ListPath而不是SimplePath?

in the generated Q class. Shouldn't it be ListPath instead of SimplePath?

推荐答案

这里有两个问题

  • Employee未被识别为实体类型,因为它没有被注释
  • Querydsl中不支持
  • ArrayList的列表类型,仅支持Collection接口
  • Employee is not recognized as an entity type, since it is not annotated
  • ArrayList is not a supported List type in Querydsl, only Collection interfaces are supported

考虑注释Employee并使用List代替ArrayList

更多推荐

queryDSL如何与接口一起工作?

本文发布于:2023-11-04 05:36:37,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1557090.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:接口   工作   queryDSL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!