你好,我有以下字符串我想分解爲休眠createAlias和查詢限制。按時間段分割字符串
我需要將字符串分成三部分。
employeeProfile.userProfile.shortname
1. employeeProfile.userProfile
2. userProfile
3. userProfile.shortName
我也喜歡它是動態做了不同長度的字符串。
employeeProfile.userProfile.anotherClass.shortname
1. employeeProfile.userProfile.anotherClass
2. userProfile.anotherClass
3. anotherClass.shortName
我能得到大部分有三個一批使用下面的代碼異常的工作。
public void hasAlias(Criteria t, final Map<String, Object> map) {
for (Map.Entry<String, Object> entry : map.entrySet()) {
String key = entry.getKey();
if (key != null && key.contains(".")) {
key = key.substring(0, key.lastIndexOf("."));
String value = key.contains(".") ? key.substring(key.lastIndexOf(".") + 1, key.length()) : key;
t.createAlias(key, value);
}
}
}
有人可以幫我拿到3號嗎?
你在哪裏獲得3號指數? –
應該是'index1'。糾正。 – iluxa
@George這不適用於第二個例子。 3號將是不正確的。 – summerbulb