关于EJB 3.0和Toplink框架的一些限制

发布于 2024-08-10 14:42:20 字数 662 浏览 4 评论 0原文

我有一个项目使用 EJB 3.0 并为模型层实现 Toplink 框架。

当使用 EJBQL 处理数据时,我发现它似乎有一些限制:

  • 它无法处理数据时间,例如查找日期的一部分,例如日、月或年
  • 它无法在 from...to 中找到日期时间
  • 它无法比较日期时间字段
  • 它不能将类而不是实体映射到自定义本机选择查询,因为我想从 SELECT 语句获取列表数据,但是当我查询时连接 2 个或更多表并将对象输出映射到类中但不可能
<块引用>

@PersistenceContext 私有 EntityManager em;

em.createNativeQuery("选择 a.用户类型,b.用户名,b.用户密码 来自表a a,表b b WHERE a.id = b.id,MyClass.class).getResultList

......

类 MyClass(){
字符串用户类型;
字符串用户名;
字符串用户密码;

}

你能帮我任何想法吗

预先感谢!

I have project use EJB 3.0 and implement Toplink framework for model layer.

When using EJBQL to process data, I see it seems have some limitation:

  • It cannot process datatime such as find a part of date such as day, month or year
  • It cannot find datetime among from...to
  • It cannot comparison datetime field
  • It cannot map a class not entity to a customize native select query because I want to get List data from SELECT statement but when I query in case join 2 or more table and map the object output into a class but impossible

@PersistenceContext private
EntityManager em;

em.createNativeQuery("SELECT
a.usertype , b.username, b.userpass
FROM tablea a, tableb b WHERE a.id =
b.id,MyClass.class).getResultList

.....

class MyClass(){
String usertype;
String username;
String userpass;

}

Could you help me any ideas?

Thank in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

红颜悴 2024-08-17 14:42:20
  • 它不能,在您的代码中执行此操作。否则,您需要在您的条件的一方面使用特定于数据库的东西。
  • 可以,为什么不呢。您可以在查询中使用 Between :fromDate 和 :toDate ,或使用 > :fromDate< :toDate,在 NamedQuery 中。问题出在哪里。
  • 可以。与上一个类似,使用=符号代替
  • 它可以使用@SqlResultSetMapping。请参阅
  • It can not, do it in your code. Otherwise, you need to use something database specific on one side of your condition.
  • It can, why not. You can use between :fromDate and :toDate in the query, or use > :fromDate and < :toDate, in the NamedQuery. Where is the problem.
  • It can. Similar to the last one, use = sign instead
  • It can using @SqlResultSetMapping. Refer to this.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文