小编all*_*rog的帖子

@Embedded对象如果没有基本数据类型字段,则不会自动实例化

基本问题:为什么@Embedded对象不会被实例化?

有趣的观察是,如果那些不包含基本数据类型(int,boolean ...)或之前未被触及的话,Ebean不会实例化@Embedded对象.例:

@Entity
public class Embedder {
    // getNotAutoInstantiated() will return null if this field was not touched before
    @Embedded
    private NotAutoInstantiated notAutoInstantiated = new NotAutoInstantiated();
    // getAutoInstantiated() will always return an instance!
    @Embedded
    private AutoInstantiated autoInstantiated = new AutoInstantiated();
}

@Embeddable
public class AutoInstantiated {
    // theKey is why this embedded object is always instantiated
    private int theKey; 
    private String field1;      
}

@Embeddable
public class NotAutoInstantiated {
    private String field2;      
}
Run Code Online (Sandbox Code Playgroud)

java jpa embeddable ebean

12
推荐指数
2
解决办法
5898
查看次数

"[App]"想要访问Twitter帐户警报未在iOS 6中显示

我正在使用TWTweetComposeViewController访问用户的Twitter帐户,他/她已在设置 - > Twitter中添加了该帐户.当应用程序尝试访问Twitter帐户时,它应该使用类似于此的消息来提示警报:

"[AppName] Would Like Access to Twitter Accounts"
Run Code Online (Sandbox Code Playgroud)

您可以点击"不允许"或"确定".我想这是操作系统本身显示的警报,因为点击"确定"实际上可以访问推特.

当我在iOS 5.x设备上测试时会显示上述警报,但在iOS 6设备上测试时则不是这种情况.我希望在发送以下消息时显示警报,并且我还没有在设置中获得我对Twitter的应用访问权限:

[TWTweetComposeViewController canSendTweet]
Run Code Online (Sandbox Code Playgroud)

如上所述,它不会发生.有谁知道这是iOS 6中的已知错误吗?我一直无法在SO上找到任何帖子,因为我找不到其他不同行为的理由我认为这是一个错误.

仅供参考,我在以下两个设备上测试:

  • 带有iOS 5.1的iPhone 4
  • 带有iOS 6.0的iPhone 4

更新

我使用DETweetComposeViewController,它以下列方式检查iOS 5:

+ (BOOL)de_isIOS5
{
    return (NSClassFromString(@"NSJSONSerialization") != nil);
}
Run Code Online (Sandbox Code Playgroud)

但由于NSJSONSerialization类也在iOS 6中表示,因此不应该这样.

twitter ios6

11
推荐指数
1
解决办法
7603
查看次数

CoreBluetooth状态保存问题:在iOS 7.1中未调用willRestoreState

CoreBluetooth状态保存问题:在iOS 7.1中未调用willRestoreState

大家好.过去几周我一直致力于蓝牙LE项目,并遇到了障碍.我无法在iOS 7/7.1中正常恢复状态.我遵循了(我认为)Apple提出的所有步骤,并在其他堆栈溢出帖子上获得了一些线索.

  1. 我为plist添加了正确的蓝牙权限
  2. 当我创建我的中央管理器时,我给它一个恢复标识符键.
  3. 我总是使用相同的密钥来实例化CM
  4. 我将willRestoreState函数添加到CM委托

我的测试用例:

  1. 连接到外围设备
  2. 确认连接
  3. 模拟内存驱逐(kill(getpid(),SIGKILL);)
  4. 传输数据

结果iOS 7:

应用程序将在AppDelegate didFinishLaunchingWithOptions函数中响应,但是launchOptions [UIApplicationLaunchOptionsBluetoothCentralsKey]内部的NSArray内容始终是一个空数组.

iOS 7.1上的结果:

进展!我可以在100%的时间内在UIApplicationLaunchOptionsBluetoothCentralsKey数组中看到我的CentralManager密钥,但永远不会调用fromRestoreState.

码:

//All of this is in AppDelegate for testing

@import CoreBluetooth;
@interface AppDelegate () <CBCentralManagerDelegate, CBPeripheralDelegate>
@property (readwrite, nonatomic, strong) CBCentralManager *centralManager;
@end

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{

    self.centralManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil options:@{CBCentralManagerOptionRestoreIdentifierKey:@“myCentralManager”}];

    //Used to debug CM restore only
    NSArray *centralManagerIdentifiers = launchOptions[UIApplicationLaunchOptionsBluetoothCentralsKey];
    NSString *str = [NSString stringWithFormat: @"%@ %lu", @"Manager Restores: ", (unsigned long)centralManagerIdentifiers.count];
    [self sendNotification:str]; …
Run Code Online (Sandbox Code Playgroud)

iphone bluetooth objective-c ios

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

EProxy URI does not resolve in ecore model

In my Ecore model all types that come from outside the current model are not resolved by their proxies. All fields of the object returned by getType() are null and only the storage type URI is filled in at runtime.

Here is an extract of my model:

<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="model" nsURI="http:///model.ecore" nsPrefix="model">
  <eSubpackages name="general" nsURI="http:///model/general.ecore" nsPrefix="model.general">
    <eClassifiers xsi:type="ecore:EClass" name="Address">
      <eStructuralFeatures xsi:type="ecore:EAttribute" name="street" ordered="false" lowerBound="1"
      eType="ecore:EDataType platform:/plugin/org.eclipse.uml2.types/model/Types.ecore#//String"/>
    </eClassifiers>
  </eSubpackages>
</ecore:EPackage>
Run Code Online (Sandbox Code Playgroud)

Currently if I make an …

eclipse-emf ecore

8
推荐指数
1
解决办法
1618
查看次数

Resteasy ProxyFactory类的替代品是什么?

我刚刚意识到ProxyFactory在RestEasy 3.0.0版本中该类被标记为已弃用.遗憾的是,弃用此类的方法无法在任何地方记录.我曾经用这种方式初始化我的服务,但新方法是什么?

protected static final String URL = "http://localhost:12345"+"/api";
protected static final MyService myService = ProxyFactory.create(MyService.class, URL); 
Run Code Online (Sandbox Code Playgroud)

java resteasy

8
推荐指数
1
解决办法
3872
查看次数

从ruby中的URL中提取锚点

我查看了ruby中URI类文档,但找不到从实例中提取锚点(HTML)的方法.例如,在

http://example.com/index.php?q=something#anchor
Run Code Online (Sandbox Code Playgroud)

我想得到anchor文字.简单的解决方案是使用正则表达式操作文本,但如果有一些方法,那么它会好得多.

ruby url anchor

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

以编程方式点击Chrome控制台中页面上的所有按钮

我正在尝试使用Chrome控制台选择页面中的所有按钮,然后以编程方式单击它们.与我正在玩的类似的页面就是这个:http://api.openstack.org/api-ref.html#compute-ext

我已经尝试执行下面的命令,但它没有做我想要的.

$("btn small info").click()
Run Code Online (Sandbox Code Playgroud)

这有可能吗?我应该发出什么命令?

html console jquery google-chrome

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

将选项添加到PreferenceScreen

我无法弄清楚如何实现一个up按钮PreferenceScreen.向上按钮会在应用程序图标旁边的操作栏中显示一个插入符号,您可以在此处浏览应用程序的层次结构,更多信息.

我有一个Preference Fragment,当我的主要活动打开时显示,我可以通过添加这行"getActionBar().setDisplayHomeAsUpEnabled(true);"来显示向上按钮:

 protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getActionBar().setDisplayHomeAsUpEnabled(true);
    getFragmentManager().beginTransaction()
    .replace(android.R.id.content, new SettingsFragment())
    .commit();
Run Code Online (Sandbox Code Playgroud)

这会导致向上按钮显示在首选项片段中,但我只想在PreferenceScreens打开其中一个时显示向上按钮,允许导航到主要PreferenceFragment.

我的应用程序类似于主要设置应用程序.只有从主设置应用程序打开的子屏幕(如位置访问)才有向上箭头.

在此输入图像描述

java android android-preferences

7
推荐指数
2
解决办法
6288
查看次数

为什么总是有空,而我使用!isEmpty 99%的时间

这个问题困扰了我很长一段时间.在编程期间,经常存在对象中是否存在某些东西的问题.出于这个原因,isEmpty发明了这种方法.很棒,但实际上我们!isEmpty几乎一直都在使用它.

因此,notEmpty对于像Java这样的语言来说,这将是一个更受欢迎的补充.问题是:为什么语言设计者在定义API之前不会想到这一点?至少给对手一个isEmpty

编辑:我的意思是应该有一个notEmpty以及isEmpty.根据域的不同,可以使用它们,但在大多数情况下,如果不涉及UI,我认为notEmpty应用得更好.

编辑2:结束讨论,这是一个例子:

!metadata.isEmpty() == metadata.notEmpty()
Run Code Online (Sandbox Code Playgroud)

我希望我们也有正确的方程式.

java

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

在maven构建结束时刷新eclipse项目

是否有可能在maven构建结束时自动刷新eclipse中项目的文件和文件夹.通常我是从命令行构建的.构建之后,例如应该刷新目标文件夹.

附加信息:maven构建在命令行中运行,eclipse应在结束时自动更新.

eclipse maven-2 maven-3 maven m2e

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