Engine中的JDO唯一字段

Engine中的JDO唯一字段

本文介绍了Google App Engine中的JDO唯一字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据,Google App Engine的JDO实现不支持JDO @Unique注释。这还是如此吗?

例如,我有这个类:

pre $ $ $ $ c> @PersistenceCapable
public class User {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
私钥键;
@Persistent
私人字符串电子邮件;
@Persistent
private String sessionToken;
...
}

显然是唯一的,但我也希望有独特的 email sessionToken 。如果不支持@Unique,那么在简单性和性能方面模拟这种行为的最佳方式是什么? 解决方案

不能更清楚。 JDO不是问题....问题在于底层的GAE / Datastore数据库不支持它(如果数据存储不支持它,那么API就无法神奇地在数据存储中强加某些东西)。该问题也提供了解决方法


According to this, Google App Engine's JDO implementation does not support JDO @Unique annotation. Is this still so?

For example, I have this class:

@PersistenceCapable
public class User {
    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Key key;
    @Persistent
    private String email;
    @Persistent
    private String sessionToken;
    ...
}

Obviously the key is unique, but I also wanted to have unique email and sessionToken. If @Unique is not supported, what's the best way to "simulate" this behaviour in terms of both simplicity and performance?

解决方案

The issue linked from that can't be clearer. JDO is not the problem .... the problem is the underlying GAE/Datastore database not supporting it (and if the datastore doesn't support it then there's no way an API can magically impose something in the datastore). That issue also gives a workaround

这篇关于Google App Engine中的JDO唯一字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 15:35