问题列表 - 第38843页

如果我有entitymanager,我如何获得会话对象

我有

private EntityManager em;

public List getAll(DetachedCriteria detachedCriteria)   {

    return detachedCriteria.getExecutableCriteria( ??? ).list();
}
Run Code Online (Sandbox Code Playgroud)

如果我使用entitymanager,我如何检索会话?如何从我的detachedcriteria获得结果?

java hibernate jpa hibernate-entitymanager

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

如何从特定变更集中克隆Mercurial存储库?

如何从特定变更集中克隆Mercurial存储库?

即:如果主仓库有变更集1-10,如何获得变更集#7中存在的源副本?

mercurial clone

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

是否可以将C++ 0x lambda转换为clang块?

我想知道是否有可能将C++ 0x lambda转换为clang块.到目前为止,我在其上看到的任何事情都涉及他们之间的分歧.我研究这个问题的主要原因是制作一个最终的包装器libdispatch,虽然我非常了解它们的dispatch_*_f功能,但与它们的块对应物相比,它们的使用信息却相当缺乏.

到目前为止,我已经能够找到有关将C++ lambda转换为函数指针的信息,但这更像是反过来的.

如果有人知道任何与此相关的内容,并且可以提供链接,或者至少指出我正确的方向,我会非常感激.(即使是"目前不可能"的答案也足够了)

c++ lambda clang c++11

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

如何处理github托管项目上的数据库凭据?

我和我的朋友正在一起开始一个Rails项目并在Github上主持回购.

我/我们应该如何使用我们的数据库凭据来确保我们不公开发布它们或破坏彼此的database.yml设置?

git security ruby-on-rails github

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

是否可以将块定义为类的成员?

我正在尝试在Objective-C中实现一个非常简单的策略类,它允许在内联定义策略而不是通过继承定义策略.目前我的代码如下所示:

@interface SSTaskStrategy : NSObject {
    (NSArray *)(^strategy)(void);
}

@end
Run Code Online (Sandbox Code Playgroud)

我认为这会奏效,但我收到了错误

在'('标记之前'的预期说明符限定符列表

任何想法如何使这项工作?

objective-c objective-c-blocks

7
推荐指数
1
解决办法
2476
查看次数

数组不是Javascript中的数据类型?

根据 Professional Javascript for Web Developers,数组不是 Javascript 中的数据类型:

\n\n
\xe2\x9d\x91   \xe2\x80\x9cundefined\xe2\x80\x9d if the value is undefined \n\xe2\x9d\x91   \xe2\x80\x9cboolean\xe2\x80\x9d if the value is a Boolean \n\xe2\x9d\x91   \xe2\x80\x9cstring\xe2\x80\x9d if the value is a string \n\xe2\x9d\x91   \xe2\x80\x9cnumber\xe2\x80\x9d if the value is a number\n\xe2\x9d\x91   \xe2\x80\x9cobject\xe2\x80\x9d if the value is an object or null \n\xe2\x9d\x91   \xe2\x80\x9cfunction\xe2\x80\x9d if the value is a function\n
Run Code Online (Sandbox Code Playgroud)\n\n

那是对的吗?

\n

javascript arrays types

4
推荐指数
1
解决办法
4344
查看次数

indexPathForRowAtPoint不会给我正确的索引

我正在尝试实现类似界面的Twitter iPhone应用程序.(滑动以使用自定义视图替换tableviewcell中的视图).我正在使用Apple UISwipeGestureRecognizer来识别滑动,我正在使用该滑动获取起始位置[recognizer locationInView:self.view].这给了我一个CGPoint,我正在使用它[tableView indexPathForRowAtPoint:location].我的问题是,我的滑动似乎总是被检测到在我刷过的实际行的上方或下方的一行.有没有人遇到过同样的问题?

编辑:我可能还应该提到我正在使用自定义tableview单元格,它的高度超过默认视图.我不确定这是否有任何区别,我正在使用它heightForRowIndexAtPath:来恢复高度.

我的代码是 -

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
ModelObject *rowData = (ModelObject *)[tempArr objectAtIndex:indexPath.row];
if (rowData.isAlternateView) {
        // Load alternateview
    UISwipeGestureRecognizer *recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipe:)];
    [recognizer setDirection:(UISwipeGestureRecognizerDirectionRight)];
    [cell addGestureRecognizer:recognizer];
    [recognizer release]; 
    return cell;

}
else {
    // Load the correct uitableviewcell
    UISwipeGestureRecognizer *recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipe:)];
    [recognizer setDirection:(UISwipeGestureRecognizerDirectionRight)];
    [cell addGestureRecognizer:recognizer];
    [recognizer release]; 

    return cell;
}

}


-(void) handleSwipe:(UISwipeGestureRecognizer *) recognizer
{
NSLog(@"Swipe …
Run Code Online (Sandbox Code Playgroud)

iphone gesture-recognition ios4

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

让C++ Builder/Delphi在启动时创建TForms,还是手动创建?

在Builder(或Delphi)中创建TForm时,会main在应用程序启动时添加代码以创建这些表单:

Application->CreateForm( __classid( TxForm), &xForm );
Run Code Online (Sandbox Code Playgroud)

这使事情变得更容易,但是当应用程序有10,20,50,100个表单时它是否明智?我假设这可以抓住各种内存和系统句柄.通过使用Project-> Options-> Forms对话框删除表单,可以在需要时随时创建表单,并且:

std::auto_ptr< TxForm > myForm( new TxForm( this ));

myForm->ShowModal();
Run Code Online (Sandbox Code Playgroud)

所以问题是,哪个更好,让C++ Builder以自己的方式完成它,或者在需要时手动创建表单?

delphi vcl c++builder

6
推荐指数
3
解决办法
1296
查看次数

无法连接到需要身份验证的smtp服务器

我正在尝试连接到需要身份验证的smtp服务器.

这是我用来发送电子邮件的C#代码:

var smtpClient = new SmtpClient();
smtpClient.Host = _smtpServerHost;
smtpClient.Credentials = new NetworkCredential(_username, _password);
smtpClient.UseDefaultCredentials = false;
smtpClient.Send(GetMessage());
Run Code Online (Sandbox Code Playgroud)

send函数引发了错误:

The SMTP server requires a secure connection or the client was not authenticated. 
The server response was: Must authenticate before sending mail
Run Code Online (Sandbox Code Playgroud)

是否有一个我缺少连接到smtp服务器的步骤?

我试图连接到我们运行的测试服务器但是没有用.我也尝试连接到smtp4dev.当我不需要身份验证时,我可以连接到它,但是当我需要身份验证时,我可以连接到它.

.net c# smtp

0
推荐指数
1
解决办法
3108
查看次数

如何从具有周期性边界条件的numpy数组中选择窗口?

假设我像这样制作一个2d数组:

>>> A=np.arange(16).reshape((4,4))
>>> A
array([[ 0,  1,  2,  3],
       [ 4,  5,  6,  7],
       [ 8,  9, 10, 11],
       [12, 13, 14, 15]])
Run Code Online (Sandbox Code Playgroud)

我希望能够在任何给定元素周围选择一个3x3窗口,以便窗口环绕边界我将如何做到这一点?我知道如果窗口的边界不与原始数组的边界重叠,我可以这样做:

>>> A[1:4,0:3]
array([[ 4,  5,  6],
       [ 8,  9, 10],
       [12, 13, 14]])
Run Code Online (Sandbox Code Playgroud)

但是如果我使用像A[i-1:i+2,j-1:j+2]它这样的表达式,只返回i = 0的空数组,例如j = 0.

python numpy

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