【发布时间】:2015-12-25 19:06:03
【问题描述】:
我有一个实体,它有一个模式列。根据与给定字符串匹配的模式来查找现有记录的最佳方法是什么?
例如:
表格记录
| ID | pattern |
| 1 | /actions/{action-id:\d+}/{type-id:\d+}/{edge:[a-z][\w]+}/draft |,
| 2 | /actions/{action-id:\d+}/{edge:[a-z][\w]+}/submit |,
| 3 | /actions/{action-id:\d+}/{type-id:\d+}/{edge:[a-z][\w]+}/request |,
| 4 | /actions/{action-id:\d+}/{edge:[a-z][\w]+}/request |,
| 5 | /actions/{action-id:\d+}/{edge:[a-z][\w]+}/terminate |
输入字符串
/actions/1/send/request
这将返回带有ID = 4 的Action 记录,因为模式/actions/{action-id:\d+}/{edge:[a-z][\w]+}/request 与输入字符串匹配。
实现这一目标的最佳方式是什么?
注意:保证输入的字符串只匹配一个 表格中的图案
.
谢谢。
【问题讨论】:
标签: java mysql regex hibernate hql