gpt4 book ai didi

java - hibernate 中的@JoinFormula

转载 作者:行者123 更新时间:2023-11-30 01:53:40 25 4
gpt4 key购买 nike

我正在开始使用 Hibernate,我遇到了这样的问题,我不明白我正在分析的代码中的这一行:

@JoinFormula( "REGEXP_REPLACE(phoneNumber, '\\+(\\d+)-.*', '\\1')::int" )

我使用的来源是:https://docs.jboss.org/hibernate/orm/5.2/userguide/html_single/Hibernate_User_Guide.html#embeddables

我不知道国家 ID 和电话号码之间的依赖关系在哪里。问候

最佳答案

在该片段之后阅读一点,您会发现

The country association in the User entity is mapped by the country identifier provided by the phoneNumber property.

还有

Therefore, the @JoinFormula annotation is used to define a custom join association between the parent-child association.

<小时/>

基本上,用户国家/地区之间的JOIN是通过该计算值进行的。

例如,一个带有号码的用户

+40-123-4567

与 ID 为

国家/地区 JOIN
40

因为 REGEXP_REPLACE 函数能够从数字推断出 40

::int 是类型转换。

关于java - hibernate 中的@JoinFormula,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55196191/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com