标签: propagation

Spring @Transactional - 隔离,传播

有人可以通过现实世界的例子解释注释中的隔离传播参数@Transactional.基本上何时以及为什么我应该选择更改其默认值.

java spring transactional isolation propagation

412
推荐指数
8
解决办法
25万
查看次数

Spring事务中requires_new和嵌套传播之间的差异

我无法理解的行为差异PROPAGATION_REQUIRES_NEWPROPAGATION_NESTED传播策略.在我看来,在这两种情况下,当前进程都是回滚的,但不是整个事务.任何线索?

java spring transactions propagation

69
推荐指数
2
解决办法
4万
查看次数

使用jQuery的Javascript:单击并双击相同的元素,不同的效果,一个禁用另一个

我有一个有趣的情况 - 我有一个表行,当前,当我点击"展开"按钮时,它显示它是隐藏的对应物.包含展开按钮的原始(未隐藏)行也包含某个单元格中的某些内容,单击该单元格后,该内容将变为可编辑状态.我想摆脱展开按钮,并通过双击行本身的任何位置来启用行的扩展,包括单击它时变为可编辑的字段.你可以在这里闻到麻烦.

当我双击一行时,在dblclick发生之前首先触发两个单击事件.这意味着如果我双击该字段,它将变为可编辑的字段,并且该行将展开.我想阻止这个.我希望双击以防止单击的触发,并且单击以执行常规操作.

使用event.stopPropagation()显然不会起作用,因为它们是两个不同的事件.

有任何想法吗?

编辑(一些半伪代码):

原始版本:

<table>
    <tbody>
        <tr>
            <td><a href="javascript:$('#row_to_expand').toggle();" title="Expand the hidden row">Expand Row</a></td>
            <td>Some kind of random data</td>
            <td><?= $editable_cell_which_turns_into_an_input_field_on_single_click[0]->value("First editable value") ?></td>
            <td><?= $editable_cell_which_turns_into_an_input_field_on_single_click[1]->value("Second editable value") ?></td>
            <td><?= $editable_cell_which_turns_into_an_input_field_on_single_click[2]->value("Third editable value") ?></td>
            <!-- ... -->
            <td><?= $editable_cell_which_turns_into_an_input_field_on_single_click[n]->value("Nth editable value") ?></td>
        </tr>
        <tr style="display: none" id="row_to_expand">
            <td colspan="n">Some hidden data</td>
        </tr>
    </tbody>
</table>
Run Code Online (Sandbox Code Playgroud)

期望的版本:

<table>
    <tbody>
        <tr ondblclick="$('#row_to_expand').toggle()">
            <td>Some kind of random data</td>
            <td><?= $editable_cell_which_turns_into_an_input_field_on_single_click[0]->value("First editable value") ?></td>
            <td><?= $editable_cell_which_turns_into_an_input_field_on_single_click[1]->value("Second editable value") ?></td>
            <td><?= $editable_cell_which_turns_into_an_input_field_on_single_click[2]->value("Third …
Run Code Online (Sandbox Code Playgroud)

javascript jquery events event-bubbling propagation

40
推荐指数
2
解决办法
9万
查看次数

如何在多线程中使用spring事务

我有一个方法如下:

ClassA.java
@Transactional
public void methodA(){        
    ExecutorService executorService = Executors.newFixedThreadPool(4);
    executorService.execute(new Runnable() {
        public void run() {
            classB.methodB();
        }
});
}
ClassB.java
@Transactional
public void methodB(){
    updateDB();
}
Run Code Online (Sandbox Code Playgroud)

方法B可以很好地工作吗?根据我的理解,methodB将附加methodA的事务,如果methodA在methodB之前退出怎么办?我想只有methodA才能被事务提交.但是因为之前提交的事务,methodB不会提交.

我可以对methodB使用@Transactional(propagation = Propagation.REQUIRES_NEW).这可以让方法B有一个新的事务.但是根据spring doc,方法A的转换将在调用methodB时暂停.我觉得这里很困惑.

任何人都可以帮我解决这个问题吗?提前致谢.

java spring multithreading transactional propagation

37
推荐指数
1
解决办法
2万
查看次数

如何在克隆时传播GIT Hook

我在我的中央存储库上编写了预提交钩子.当我的客户端克隆存储库时,它永远不会传播挂钩.我想将钩子也复制到我的客户端存储库.我的客户是Windows用户,使用msysgit作为git客户端.

有什么办法可以将钩子复制到本地存储库吗?

git propagation pre-commit-hook git-clone

25
推荐指数
2
解决办法
8439
查看次数

使用jQuery捕获和冒泡

我是jQuery的新手,我正在尝试理解捕获和冒泡的概念.

我已经阅读了很多文章,但大多数都描述了Javascript的事件传播.

让我们假设我们有以下HTML代码:

<div id="outter">

        outter

        <div id="inner">

                inner
        </div>

</div>
Run Code Online (Sandbox Code Playgroud)

捕获是我们沿着DOM元素走下去的阶段,冒泡就是我们上升的时候.

在Javascript中,您可以决定使用哪种方式(使用true或false参数):

element.addEventListener('click',doSomething,true) --> capture phase
element.addEventListener('click',doSomething,false)  --> bubble phase
Run Code Online (Sandbox Code Playgroud)

有没有类似的jQuery来表示除JavaScript方式之外的哪种方式?

jQuery也使用默认阶段吗?比如泡泡?

因为我使用以下代码来测试这个:

CSS

<style>

  div {
            border: 1px solid green;
            width: 200px;

       }

</style>
Run Code Online (Sandbox Code Playgroud)

jQuery的

<script>

    $(document).ready(function(){

        $('div').click(function(){
            $(this).animate({'width':'+=10px'},{duration: 3000})
        });

    });

</script>
Run Code Online (Sandbox Code Playgroud)

看来,当我点击outter div时,只有那个div动画到更大的div.当我点击内部div时,两个div都会生成更大的div.

我不知道我是不是错了,但是这个测试表明默认的浏览器传播方法是冒泡的.

如果我错了,请纠正我.

html javascript jquery event-bubbling propagation

25
推荐指数
3
解决办法
3万
查看次数

外行人的术语中的春季传播例子

Spring文档在描述事务传播属性方面做得非常出色.

但是,我想知道是否有任何众所周知的现实世界的例子可以用外行的方式更全面地描述这些属性?

java spring annotations transactional propagation

22
推荐指数
1
解决办法
7282
查看次数

jQuery on()stopPropagation不工作?

我似乎无法让这个停止传播..

  $(document).ready(function(){
      $("body").on("click","img.theater",function(event){ 
          event.stopPropagation();    
          $('.theater-wrapper').show();
      }); 

       // This shouldn't fire if I click inside of the div that's inside of the 
       // `.theater-wrapper`, which is called `.theater-container`, anything else it should.
       $(".theater-wrapper").click(function(event){
           $('.theater-wrapper').hide();
       }); 
  });
Run Code Online (Sandbox Code Playgroud)

请参考这个jsfiddle

javascript jquery propagation stoppropagation

20
推荐指数
1
解决办法
3万
查看次数

jQuery:陷阱所有点击事件发生之前?

在我的页面上,我有很多响应点击事件的元素.有时我需要根据某些全局标志来阻止所有点击.有没有办法在集中的位置进行检查?

现在我在每个事件中检查标志,例如:

var canClick = false; // Global flag

// Sample click event:
$("#someDiv").click(function(){
  if(!canClick) return;

  // Some stuff ...
});
Run Code Online (Sandbox Code Playgroud)

我想做的是有一个元素任何其他元素之前捕获所有点击事件.

我尝试在文档上执行此操作但这些事件仅在其他单击事件之后发生.

例:

$("#someDiv").click(function(){ console.log("someDiv click"); });

$(document).click(function(){ console.log("Document click"); });

// When I click on the someDiv element it prints:
> someDiv click
> Document click
Run Code Online (Sandbox Code Playgroud)

我还尝试在所有内容之上放置一个全屏div并使用它来捕获事件,但问题是没有任何点击通过这个全屏div传播.此外,我不想依赖于创建额外的元素来捕获点击,因为它感觉有点hacky.

我可以覆盖jQuery点击功能,以便我可以把我的小支票放在那里吗?

有什么明显的东西我在这里不见了吗?

谢谢你的帮助.

jquery events click propagation

17
推荐指数
1
解决办法
2万
查看次数

嵌套属性中的Rails/Mongoid错误消息

我有一个定义如下的联系信息类:

class ContactInfo
  include Mongoid::Document

  validates_presence_of :name, :message => ' cannot be blank'

  field :name, :type => String
  field :address, :type => String
  field :city, :type => String
  field :state, :type => String
  field :zip, :type => String
  field :country, :type => String
  embedded_in :user
end
Run Code Online (Sandbox Code Playgroud)

此联系信息类嵌入在我的用户类中的嵌套属性:

class PortalUser
  include Mongoid::Document
  accepts_nested_attributes_for :contact_info
end
Run Code Online (Sandbox Code Playgroud)

当我尝试保存没有名称的用户时,我收到如下错误消息:

联系信息无效

但是,这对最终用户来说不是很有用,因为他或她不知道哪些联系信息无效.REAL消息应为"名称不能为空".但是,此错误不会向上传播.有没有办法让user.errors中的'Name not not blank'消息而不是'Contact info is invalid'错误消息?

谢谢

validation nested propagation mongoid

14
推荐指数
1
解决办法
4195
查看次数