2015-11-14 46 views
0

我目前正在开发一个需要将数据插入到azure Mobile Service数据库中的android应用程序。准确地说,一个id字符串和一个第一个登录整数。但是,正在抛出以下错误。插入数据“MobileServiceTable必须定义一个id属性”

“抛出:IllegalArgumentException:表示MobileServiceTable的类必须定义一个单一的id属性”

id值,我需要插入到数据库中正在使用passId片段接口传递回( )。在这里覆盖的内容是我试图将值插入azure,如下所示。

@Override 
public void passId(String id) { 

    userInstance user = new userInstance(); 
    user.user_id = id; 
    user.first_login = 0; 
    mClient.getTable(userInstance.class).insert(user, new TableOperationCallback<userInstance>() { 
     public void onCompleted(userInstance entity, Exception exception, ServiceFilterResponse response) { 
      if (exception == null) { 
       // Insert succeeded 
      } else { 
       // Insert failed 
      } 
     } 
    }); 

移动客户端VAR代表MobileServicesClient如下图所示

try { 

     mClient = new MobileServiceClient(
       "https://xxxx.azure-mobile.net/", 
       "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", 
       this); 

    } catch (MalformedURLException e) { 
     e.printStackTrace(); 
    } catch (Exception e){ 
     e.printStackTrace(); 
    } 

表名,我试图将数据插入到是“USER_TABLE”有没有什么帮助的。

我希望你能提供帮助,并提前感谢你们给我的任何帮助。

回答

1

SOLUTION:

因为我试图将数据添加到汽车的Azure Table中创建的“ID”列中,我用构建用户信息的用户对象插入到数据库的人不得不定义一个“id”字符串。如下图所示:

public class userInstance { 

    @com.google.gson.annotations.SerializedName("id") 
    public String mId; 

    @com.google.gson.annotations.SerializedName("user_id") 
    public String mUserId; 

    @com.google.gson.annotations.SerializedName("first_login") 
    public int mLogin; 

} 
相关问题