如何在休眠中处理find_in_set?
How to deal with find_in_set in hibernate?
对于“Student”table,有一列为“Friend-Names”。
在该列中,值为“rahul、kuldeep、rachana、vivek” 等
我必须从 "Student" table 中获取那些记录,其中 "Friend-Names" 列包含 "kuldeep"。
我得到了 find_in_set 关键字,但它不适用于休眠。
谁能告诉我如何使用 hibernate 处理这种情况?如何在不使用或使用 find_in_set 使用 hibernate 的情况下处理此类情况?
我几乎可以肯定,hibernate 不提供 find_in_set 功能。所以,你可以做两件事 -
- 您可以为 mysql 方言声明 find_in_set 函数(错误的决定,因为它只适用于 mysql)
- 您可以重新构建您的数据库结构,并在其他 table 中保留好友名称。不仅仅是添加加入它。
第二种情况更好。
对于“Student”table,有一列为“Friend-Names”。 在该列中,值为“rahul、kuldeep、rachana、vivek” 等
我必须从 "Student" table 中获取那些记录,其中 "Friend-Names" 列包含 "kuldeep"。
我得到了 find_in_set 关键字,但它不适用于休眠。 谁能告诉我如何使用 hibernate 处理这种情况?如何在不使用或使用 find_in_set 使用 hibernate 的情况下处理此类情况?
我几乎可以肯定,hibernate 不提供 find_in_set 功能。所以,你可以做两件事 -
- 您可以为 mysql 方言声明 find_in_set 函数(错误的决定,因为它只适用于 mysql)
- 您可以重新构建您的数据库结构,并在其他 table 中保留好友名称。不仅仅是添加加入它。
第二种情况更好。