如何使用Hibernate比较两个不同表中的字段?(How do I compare fields in two different tables using Hibernate?)

编程入门 行业动态 更新时间:2024-10-19 10:25:28
如何使用Hibernate比较两个不同表中的字段?(How do I compare fields in two different tables using Hibernate?)

我需要使用Hibernate查询比较来自2个不同表的字段。

表A具有由sectionId(例如1900)组成的字段。

表B具有由userId / sectionId组成的字段(例如e1230-12w11-3ewq-qg22-34qa / 1900)。

我需要从表B中提取sectionId并将其与表A中的sectionId进行比较,以便我可以为新表构建一行。 我还需要从表B中提取userId并将其用作此新行的一部分。

hql能否部分比较字段?

I need to compare fields from 2 different tables using Hibernate queries.

Table A has a field which consists of sectionId(eg 1900).

Table B has a field which consists of userId/sectionId(eg e1230-12w11-3ewq-qg22-34qa/1900).

I need to extract sectionId from table B and compare it with sectionId in table A so that I can build a row for a new table. I also need to extract userId from table B and use it as a part of this new row too.

Does hql have the ability to compare fields partially?

最满意答案

我认为您可以使用JPQL函数执行此操作: SUBSTRINGLOCATE

LOCATE将能够在输入字符串中找到特定字符并返回它的位置。 然后你应该能够使用SUBSTRING根据LOCATE返回的索引返回字符串的一部分。

I think you can do this using JPQL functions: SUBSTRING and LOCATE.

LOCATE will be able to locate the particular character in your input string and will return it's place. Then you should be able to use SUBSTRING to return just a part of the string based on the index returned by LOCATE.

更多推荐

本文发布于:2023-08-01 19:06:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1363719.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字段   如何使用   两个   Hibernate   tables

发布评论

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

>www.elefans.com

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