NHibernate MySql事务不会回滚(NHibernate MySql transaction does not rollback)
我用一个MySql数据库使用nhibernate。
大多数CRUD操作按预期工作,除了回滚事务。 下面的代码是我的; 非常简单,创建一个实体,保存它,然后回滚。
using (var tran = accountRepository.Session.BeginTransaction()) { var newUser = new User(); newUser.Username = "testuser1002"; accountRepository.Session.Save(newUser); tran.Rollback(); }
代码产量预期会导致我的SqlServer配置,但是,它不适用于MySql配置。 这两种配置几乎相同。
i am using nhibernate with a MySql database.
Most CRUD operations work as expected except rolling back a transaction. The following code is what i have; really straightforward, create an entity, save it, then rollback.
using (var tran = accountRepository.Session.BeginTransaction()) { var newUser = new User(); newUser.Username = "testuser1002"; accountRepository.Session.Save(newUser); tran.Rollback(); }
The code yield expected result in my SqlServer configuration, however, it does not work with the MySql configuration. These 2 configurations are pretty much the same.
原文:https://stackoverflow.com/questions/6659631
最满意答案
正则表达式不能处理重复组,它可以返回任何捕获的组(在你的情况下它返回
"Ghi"
)。下面的例子将打印:
Abc Def Ghi 12345
代码:
public static void main(String[] args) { String example = "AbcDefGhi12345"; if (example.matches("(([A-Z][a-z]+)+)([0-9]+)")) { Scanner s = new Scanner(example); String m; while ((m = s.findWithinHorizon("[A-Z][a-z]+", 0)) != null) System.out.println(m); System.out.println(s.findWithinHorizon("[0-9]+", 0)); } }
Regular expressions cannot handle repeating groups it can return any of the captured groups (in your case it returned
"Ghi"
).The example below will print:
Abc Def Ghi 12345
The code:
public static void main(String[] args) { String example = "AbcDefGhi12345"; if (example.matches("(([A-Z][a-z]+)+)([0-9]+)")) { Scanner s = new Scanner(example); String m; while ((m = s.findWithinHorizon("[A-Z][a-z]+", 0)) != null) System.out.println(m); System.out.println(s.findWithinHorizon("[0-9]+", 0)); } }
相关问答
更多-
总之:你不能。 一个匹配总是连续的,即使它包含了作为零宽度断言的东西,如果你想要后面的一个匹配下一个字符,也无法匹配下一个字符。 In short: You can't. A match is always consecutive, even when it contains things as zero-width assertions there is no way around matching the next character if you want to get to the one afte ...
-
考虑使用BreakIterator : String text = "मछली"; Locale hindi = new Locale("hi", "IN"); BreakIterator breaker = BreakIterator.getCharacterInstance(hindi); breaker.setText(text); int start = breaker.first(); for (int end = breaker.next(); end != BreakIterator.DO ...
-
str_match() ,从stringr包,将这样做。 它为匹配中的每个组返回一个字符矩阵(每个组有一列): > s = c("(sometext :: 0.1231313213)", "(moretext :: 0.111222)") > str_match(s, "\\((.*?) :: (0\\.[0-9]+)\\)") [,1] [,2] [,3] [1,] "(sometext :: 0.123131321 ...
-
正则表达式不能处理重复组,它可以返回任何捕获的组(在你的情况下它返回"Ghi" )。 下面的例子将打印: Abc Def Ghi 12345 代码: public static void main(String[] args) { String example = "AbcDefGhi12345"; if (example.matches("(([A-Z][a-z]+)+)([0-9]+)")) { Scanner s = new Scanner(example); ...
-
你想要一个积极的前瞻: \d+(?=:$) 非捕获组只是一个无法通过反向引用访问的组; 尽管如此,他们仍然是比赛的一部分。 或者,您可以使用 (\d+):$ 并获得第一场比赛组。 You want a positive lookahead: \d+(?=:$) A non-capturing group is simply a group that cannot be accessed via a backreference; they still are part of the match, non ...
-
括号仅用于正则表达式匹配中的捕获组?(parentheses only used for capture group in regular expression matching?)[2022-01-08]
括号用于分组,这将使正则表达式引擎捕获括号内的子模式。 如果您不想使用此语法在非捕获组内捕获文本: (?:...) 这也将在处理长而复杂的正则表达式时节省一些内存。 查看有关非捕获组的更多信息 如果正则表达式是这样的话,应该如何谨慎放置ad where ()的基本和简单示例 ^\w+|\d+$ 我们在输入处选择开头的单词或结尾处的数字: foo -a123 bar baz 123 因此我们匹配foo和123 。 如果你像这样放置方括号() : ^(\w+|\d+)$ 然后你的匹配将失败,因为我们断言 ... -
根据这个 flag match_not_dot_newline ,你必须将flag match_not_dot_newline传递给匹配算法。 我认为这会解决你的情况。 acording to this articale you have to pass flag match_not_dot_newline to the matching algorithm. i think that would solve your case.
-
使用Python正则表达式捕获组的所有重复(Capture all repetitions of a group using Python regular expression)[2022-07-03]
通过简单的字符串操作,您可以更清楚地了解它。 my_string = '1: foo bar baz' num_string, word_string = my_string.split(':') num = int(num_string) words = word_string.strip().split(' ') print(num) print(words) 输出: # num = 1 # words = ['foo', 'bar', 'baz'] You can probably make i ... -
您需要第一个捕获的组: a.group(1) b.group(1) ... 没有任何捕获的组规范作为group()参数,它将显示完全匹配,就像你现在得到的那样。 这是一个例子: In [8]: string_one = 'file_record_transcript.pdf' In [9]: re.search(r'^(file.*)\.pdf$', string_one).group() Out[9]: 'file_record_transcript.pdf' In [10]: re.search( ...
-
你是对的,这是关于贪婪的。 找到第一个匹配组的分隔符。 因此,如果您的名字“never”包含短划线,则只匹配除第一个匹配组的短划线以外的所有内容。 firstName:([^-]*)(?:-lastName:(.*))? firstName:([^-]*)(?:-lastName:(.*))? Debuggex演示 如果找不到这样的分隔符,则需要采用不同的方法。 即使你试图使第一个模式“懒惰”,正则表达式引擎总是更喜欢匹配额外的可选匹配。 这是因为懒惰的 匹配组将匹配满足表达式的第一个字符串 (!重要的 ...