简体   繁体   中英

Azure SQL: null fields on get()

I have a table Friends that I use to store relations between my Users .

I can send data to the table with no problem, all the fields have the desired value. But when I try to get the data from de DB, all the fields but Id are null.

Any idea ? Thanks !

The code:

Static.mClient.getTable(Friends.class).insert(f1).get();
Static.mClient.getTable(Friends.class).insert(f2).get();

System.out.println("Added friends !");
System.out.println(f1.Id + ": " + f1.User1 + " <-> " + f1.User2);
System.out.println(f2.Id + ": " + f2.User1 + " <-> " + f2.User2);

System.out.println("Now getting data...")
List<Friends> l = Static.mClient.getTable(Friends.class).execute().get();
for (Friends friends : l) {
    System.out.println(friends.Id + ": " + friends.User1 + " <-> " + friends.User2);
}

The output:

06-14 16:44:41.916 8504-8557/com.travel2gather I/System.out: Added friends !
06-14 16:44:41.916 8504-8557/com.travel2gather I/System.out: 8744e40ba601402cae229c0ebd2a3e7d: ec99e0f1d61447deb246477f551dddb2 <-> 1c7fcc47a03c4063a0e4f8fcd4a0fb97
06-14 16:44:41.916 8504-8557/com.travel2gather I/System.out: 7da1c6905d7e495bbd1fecfa33b4a8f3: ec99e0f1d61447deb246477f551dddb2 <-> 751631d38737493aadef399474bb0a13
06-14 16:44:41.916 8504-8557/com.travel2gather I/System.out: Now getting data...
06-14 16:47:30.322 10840-10889/com.travel2gather I/System.out: 7da1c6905d7e495bbd1fecfa33b4a8f3: null <-> null
06-14 16:47:30.322 10840-10889/com.travel2gather I/System.out: 8744e40ba601402cae229c0ebd2a3e7d: null <-> null

But when I check the DB, I can see that the fields User1 and User2 are not null and have the values they are supposed to have...

This may caused by losing 'get' methods for User1 and User2 in your Friends class. Add 'get' and 'set' methods for all properties then try again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM