我正在学习JPA,示例中的一般模式似乎如下:
EntityManager em = factory.createEntityManager();
em.getTransaction().begin();
// ....
em.getTransaction().commit();
em.close();
Run Code Online (Sandbox Code Playgroud)
现在我想知道为什么我们不断创建和关闭EntityManagers,而不是保持开放并且只是开始新的交易?保持开放与关闭它的好处和成本是什么?
查询1:占用最长时间的前10个代码
select top 10
source_code,
stats.total_elapsed_time/1000000 as seconds,
last_execution_time from sys.dm_exec_query_stats as stats
cross apply(SELECT
text as source_code
FROM sys.dm_exec_sql_text(sql_handle)) AS query_text
order by total_elapsed_time desc
Run Code Online (Sandbox Code Playgroud)
Query2:占用最大physical_reads的前10个代码
select top 10
source_code,
stats.total_elapsed_time/1000000 as seconds,
last_execution_time from sys.dm_exec_query_stats as stats
cross apply(SELECT
text as source_code
FROM sys.dm_exec_sql_text(sql_handle)) AS query_text
order by total_physical_reads desc
Run Code Online (Sandbox Code Playgroud)
取自本文
在我的Windows Phone 7应用程序中,我有一个单行文本框.当用户按下{ENTER}时,我想接受文本框值并将文本框切换回正常的非编辑模式.
基本上,有没有办法以编程方式取消编辑文本框?
我已经尝试将视觉状态管理器强制进入正常模式,该模式确实改变了视觉样式,但文本框仍处于编辑模式,并且仍然显示屏幕键盘.
VisualStateManager.GoToState(
this.MyTextBox,
"Normal",
true);
VisualStateManager.GoToState(
this.MyTextBox,
"Unfocused",
true);
Run Code Online (Sandbox Code Playgroud)
还尝试以编程方式选择父控件,但似乎也不起作用.
我想我必须错过一些简单的事情,有人必须做了一百万次 - 任何帮助都非常感激.
谢谢,
更新:我试图将焦点设置为另一个控件,但这不起作用,SIP键盘永远不会消失.
但我用另一种方法想出来了.诀窍是使用IsReadOnly标志.当失去焦点或输入被按下时,我将控件设置为只读更新样式.我所要做的就是更新我的视觉效果,使它看起来正确,现在效果很好.
对于它的价值,我的代码现在看起来像这样:
private void MyTextBox_GotFocus(object sender, RoutedEventArgs e)
{
this.MyTextBox.IsReadOnly = false;
this.MyTextBox.SelectAll();
}
private void MyTextBox_LostFocus(object sender, RoutedEventArgs e)
{
this.MyTextBox.IsReadOnly = true;
}
private void MyTextBox_KeyUp(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
this.MyTextBox.IsReadOnly = true;
VisualStateManager.GoToState(
this.MyTextBox,
"ReadOnly",
true);
VisualStateManager.GoToState(
this.MyTextBox,
"Unfocused",
true);
VisualStateManager.GoToState(
this.MyTextBox,
"Valid",
true);
}
}
Run Code Online (Sandbox Code Playgroud) 1)为什么在Java包中的文件中我应该在其中编写"包"内容?它不是间接地假设如果它在目录中,那么它在包中?
2)我来自C++世界.我总是从其他使用该类的文件中导入我需要的类的.h(我的意思是,我只想"显示"标题,而不是实现).但现在我对Java的进口感到有些困惑.这是如何在Java中完成的?
谢谢
我正在关注http://developer.apple.com/iphone/library/qa/qa2010/qa1702.html上的参考资料,以从iPhone摄像头捕获视频.除了该页面的代码之外,这是一个新项目.我也将AVFoundation框架添加到项目中.这是我得到的链接器错误:
Build my project of project my project with configuration Debug
CompileC "build/my project.build/Debug-iphoneos/my project.build/Objects-normal/armv6/MainViewController.o" /Users/mwilliamson/Projects/my_project/iphone/Classes/MainViewController.m normal armv6 objective-c com.apple.compilers.gcc.4_2
cd /Users/mwilliamson/Projects/my_project/iphone
setenv LANG en_US.US-ASCII
setenv PATH "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/opt/local/bin:/usr/local/git/bin"
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 -x objective-c -arch armv6 -fmessage-length=0 -pipe -std=c99 -Wno-trigraphs -fpascal-strings -O0 -Wreturn-type -Wunused-variable -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.0.sdk -fvisibility=hidden -gdwarf-2 -mthumb -miphoneos-version-min=4.0 -iquote "/Users/mwilliamson/Projects/my_project/iphone/build/my project.build/Debug-iphoneos/my project.build/my project-generated-files.hmap" "-I/Users/mwilliamson/Projects/my_project/iphone/build/my project.build/Debug-iphoneos/my project.build/my project-own-target-headers.hmap" "-I/Users/mwilliamson/Projects/my_project/iphone/build/my project.build/Debug-iphoneos/my project.build/my project-all-target-headers.hmap" -iquote "/Users/mwilliamson/Projects/my_project/iphone/build/my project.build/Debug-iphoneos/my project.build/my project-project-headers.hmap" -F/Users/mwilliamson/Projects/my_project/iphone/build/Debug-iphoneos -I/Users/mwilliamson/Projects/my_project/iphone/build/Debug-iphoneos/include -I/Users/mwilliamson/Projects/my_project/iphone/opencv_device/include "-I/Users/mwilliamson/Projects/my_project/iphone/build/my project.build/Debug-iphoneos/my project.build/DerivedSources/armv6" "-I/Users/mwilliamson/Projects/my_project/iphone/build/my project.build/Debug-iphoneos/my project.build/DerivedSources" -include /var/folders/kW/kW6u6B7SGyGYu+nNumtIa++++TI/-Caches-/com.apple.Xcode.501/SharedPrecompiledHeaders/my_project_Prefix-alujyqxskcuyuogdsynmjyrkxbhh/my_project_Prefix.pch -c /Users/mwilliamson/Projects/my_project/iphone/Classes/MainViewController.m …Run Code Online (Sandbox Code Playgroud) 你能告诉我们如何使用stl:map作为二维数组吗?我想像mymap [i] [j]那样访问各个元素,我事先不知道i或j的值是什么.有没有更好的想法以其他方式做同样的事情?
我有一个这样的表格:
<form action="lol.php" method="POST">
<input type="text" name="fe" />
<input type="submit" id="submitbtn" value="submit" onclick="this.disabled = true;" />
</form>
Run Code Online (Sandbox Code Playgroud)
并且在Firefox中它可以很好地工作,但在Internet Explorer(最新版本)中,该按钮被禁用但表单未提交.我也尝试过:
<form action="lol.php" method="POST" onsubmit="document.getElementById('submitbtn').disabled = true">
Run Code Online (Sandbox Code Playgroud)
并从提交按钮中删除了onclick代码,但效果相同.我应该使用什么代码才能在所有浏览器上运行?
我希望有人可以建议一些使用数据库配置Rails应用程序的最佳实践(即将配置设置持久保存到数据库而不是平面文件).我的理由是我有一个应用程序将在多个服务器上运行,并且有一些相当动态的配置设置,我想要更改它们而不必在每个服务器上进行更改.
在其他语言中,我通过使用简单的配置表(如名称/值对)和公开配置数据并定期刷新的单例来完成此操作.使用Rails是否有类似或更好的方法?
提前致谢.
我在MVVM-Light包中看到我可以用令牌发送消息 - 我需要做的是发送一个对象,并在该对象上附加一条消息,如添加,编辑,删除等等.
发送和接收此消息的最佳方式是什么?我认为发送它只是:Messenger.Default.Send(myObject,ActionEnum.DELETE);
但在接收:Messenger.Default.Register(this,????,HandleMyMessage);
什么是正确的语法?
谢谢!
我知道有相当数量的C++,现在我想探索制作游戏.我想知道在编写仍然跨平台的硬件加速游戏(Windows/OSX/Linux)方面最好的方法是什么.这将是一个2D游戏,但足够密集,CPU渲染器可能不会削减它.
我知道有OpenGL,但我似乎找不到任何关于如何以跨平台方式使用它的教程,它们都集中在一个平台上.
使用SDL也是一种可能性,但我担心如果我使用它,游戏可能效果不佳.这一定是真的吗?
最后,我看过像http://www.sfml-dev.org/这样的图书馆,如果我沿着那条路走下去,那应该会让它变得更容易?
再次感谢.
c++ ×2
java ×2
avfoundation ×1
database ×1
forms ×1
header ×1
html ×1
iphone ×1
javascript ×1
jpa ×1
mvvm-light ×1
mysql ×1
opengl ×1
orm ×1
package ×1
ruby ×1
sdl ×1
silverlight ×1
sql-server ×1
stl ×1