I have used objectify to query the GAE datastore i have set up that has at least one entity in it but i keep getting the following response
200 OK
Show headers -
{
"kind": "call#resourcesItem",
"etag": "\"AiR-q6YO1YYMgAaz-ZfT_fl7oeY/pcKQAVaDylr_ZSckRfQAxsphOUU\""
}
here is what the objectify request looks like
#ApiMethod(name = "queryCalls", path = "queryCalls", httpMethod = HttpMethod.POST)
public List<Call> queryCalls()
{
Query<Call> query = ofy().load().type(Call.class).order("name");
return query.list();
}
Call is obviously the class of the entity that is being used.
Any solutions would be most appreciated
EDIT
Here is the call class for reference
package com.cms.log;
import com.googlecode.objectify.annotation.Entity;
import com.googlecode.objectify.annotation.Id;
import com.googlecode.objectify.annotation.Index;
/* Patient Entity */
#Entity
public class Call {
#Id Long callId;
#Index String patientName;
#Index String doctor;
String address1;
String address2;
String address3;
String postCode;
String patientLocation;
#Index String symptoms;
Integer contactNumber;
#Index String callDateTime;
String currentStatus;
public Call(Long callId, String patientName, String doctor, String address1,
String address2, String address3, String postCode, String patientLocation, String symptoms,
Integer contactNumber, String callDateTime, String currentStatus)
{
this.callId = callId;
this.patientName = patientName;
this.doctor = doctor;
this.address1 = address1;
this.address2 = address2;
this.address3 = address3;
this.postCode = postCode;
this.patientLocation = patientLocation;
this.symptoms = symptoms;
this.contactNumber = contactNumber;
this.callDateTime = callDateTime;
this.currentStatus = currentStatus;
};
public Long getCallId() {
return callId;
}
public void setCallId(Long Id) {
this.callId = Id;
}
public String getPatientName() {
return patientName;
}
public void setPatientName(String patientName) {
this.patientName = patientName;
}
public String getDoctor() {
return doctor;
}
public void setDoctor(String doctor) {
this.doctor = doctor;
}
public String getAddress1() {
return address1;
}
public void setAddress1(String address1) {
this.address1 = address1;
}
public String getAddress2() {
return address2;
}
public void setAddress2(String address2) {
this.address2 = address2;
}
public String getAddress3() {
return address3;
}
public void setAddress3(String address3) {
this.address3 = address3;
}
public String getPostCode() {
return postCode;
}
public void setPostCode(String postCode) {
this.postCode = postCode;
}
public String getPatientLocation() {
return patientLocation;
}
public void setPatientLocation(String patientLocation) {
this.patientLocation = patientLocation;
}
public String getSymptoms() {
return symptoms;
}
public void setSymptoms(String symptoms) {
this.symptoms = symptoms;
}
public int getContactNumber() {
return contactNumber;
}
public void setContactNumber(int contactNumber) {
this.contactNumber = contactNumber;
}
public String getCallDateTime() {
return callDateTime;
}
public void setCallDateTime(String callDateTime) {
this.callDateTime = callDateTime;
}
public String getCurrentStatus() {
return currentStatus;
}
public void setCurrentStatus(String currentStatus) {
this.currentStatus = currentStatus;
}
}
As you have highlighted in your last comment, your #Entity classes must have a no-arg constructor in order for Objectify to be able to construct objects from Datastore entities.
Once that is sorted you will be able to order your results using #Indexed properties defined in your class.
Related
I'm Trying to call API using retrofit in Android. Although I'm successfully able to api in response I'm getting Success Code = 200. But Apart from that Inside Json object Json array is null although while I'm trying to call same api in Postman I'm getting the desire result.
I'm trying to call using POST request
URL Request :- https://example.com/AD1/api/user/profile
I'm passing parameter in Body userid:- MFL176116
Below Postman
APIInterface.java
public interface APIInterface {
#POST("profile")
Call<ProfilePojo> getUserProfile(#Body ProfilePojo profilePojo);
}
ProfilePojo.java
public class ProfilePojo {
#SerializedName("message")
#Expose
private String message;
#SerializedName("code")
#Expose
private Integer code;
#SerializedName("user_data")
#Expose
private List<UserDatum> userData = new ArrayList();
private String userid;
public ProfilePojo(String userid) {
this.userid = userid;
}
public String getUserid() {
return userid;
}
public void setUserid(String userid) {
this.userid = userid;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public List<UserDatum> getUserData() {
return userData;
}
public void setUserData(List<UserDatum> userData) {
this.userData = userData;
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public class UserDatum {
#SerializedName("id")
#Expose
private String id;
#SerializedName("username")
#Expose
private String username;
#SerializedName("password")
#Expose
private String password;
#SerializedName("under_id")
#Expose
private String underId;
#SerializedName("place_under_id")
#Expose
private String placeUnderId;
#SerializedName("mobile")
#Expose
private String mobile;
#SerializedName("side")
#Expose
private String side;
#SerializedName("email")
#Expose
private String email;
#SerializedName("status")
#Expose
private String status;
#SerializedName("member_name")
#Expose
private String memberName;
#SerializedName("package_id")
#Expose
private String packageId;
#SerializedName("package_id1")
#Expose
private String packageId1;
#SerializedName("avatar")
#Expose
private String avatar;
#SerializedName("gender")
#Expose
private Object gender;
#SerializedName("date_of_birth")
#Expose
private Object dateOfBirth;
#SerializedName("address_line1")
#Expose
private String addressLine1;
#SerializedName("address_line2")
#Expose
private String addressLine2;
#SerializedName("country")
#Expose
private String country;
#SerializedName("country_code")
#Expose
private String countryCode;
#SerializedName("state")
#Expose
private String state;
#SerializedName("city")
#Expose
private String city;
#SerializedName("pincode")
#Expose
private String pincode;
#SerializedName("pancard_no")
#Expose
private String pancardNo;
#SerializedName("adharcard_no")
#Expose
private String adharcardNo;
#SerializedName("franchaise_type")
#Expose
private String franchaiseType;
#SerializedName("franchise_id")
#Expose
private Object franchiseId;
#SerializedName("franchise_per")
#Expose
private Object franchisePer;
#SerializedName("franchise_status")
#Expose
private Object franchiseStatus;
#SerializedName("transaction_pass")
#Expose
private String transactionPass;
#SerializedName("id_proof")
#Expose
private Object idProof;
#SerializedName("address_proof")
#Expose
private Object addressProof;
#SerializedName("self_video")
#Expose
private String selfVideo;
#SerializedName("residential_proof")
#Expose
private String residentialProof;
#SerializedName("btc_address")
#Expose
private Object btcAddress;
#SerializedName("perfect_money")
#Expose
private Object perfectMoney;
#SerializedName("email_status")
#Expose
private String emailStatus;
#SerializedName("email_verify")
#Expose
private String emailVerify;
#SerializedName("created_on")
#Expose
private String createdOn;
#SerializedName("edited_on")
#Expose
private String editedOn;
#SerializedName("isDeleted")
#Expose
private String isDeleted;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getUnderId() {
return underId;
}
public void setUnderId(String underId) {
this.underId = underId;
}
public String getPlaceUnderId() {
return placeUnderId;
}
public void setPlaceUnderId(String placeUnderId) {
this.placeUnderId = placeUnderId;
}
public String getMobile() {
return mobile;
}
public void setMobile(String mobile) {
this.mobile = mobile;
}
public String getSide() {
return side;
}
public void setSide(String side) {
this.side = side;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getMemberName() {
return memberName;
}
public void setMemberName(String memberName) {
this.memberName = memberName;
}
public String getPackageId() {
return packageId;
}
public void setPackageId(String packageId) {
this.packageId = packageId;
}
public String getPackageId1() {
return packageId1;
}
public void setPackageId1(String packageId1) {
this.packageId1 = packageId1;
}
public String getAvatar() {
return avatar;
}
public void setAvatar(String avatar) {
this.avatar = avatar;
}
public Object getGender() {
return gender;
}
public void setGender(Object gender) {
this.gender = gender;
}
public Object getDateOfBirth() {
return dateOfBirth;
}
public void setDateOfBirth(Object dateOfBirth) {
this.dateOfBirth = dateOfBirth;
}
public String getAddressLine1() {
return addressLine1;
}
public void setAddressLine1(String addressLine1) {
this.addressLine1 = addressLine1;
}
public String getAddressLine2() {
return addressLine2;
}
public void setAddressLine2(String addressLine2) {
this.addressLine2 = addressLine2;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getCountryCode() {
return countryCode;
}
public void setCountryCode(String countryCode) {
this.countryCode = countryCode;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getPincode() {
return pincode;
}
public void setPincode(String pincode) {
this.pincode = pincode;
}
public String getPancardNo() {
return pancardNo;
}
public void setPancardNo(String pancardNo) {
this.pancardNo = pancardNo;
}
public String getAdharcardNo() {
return adharcardNo;
}
public void setAdharcardNo(String adharcardNo) {
this.adharcardNo = adharcardNo;
}
public String getFranchaiseType() {
return franchaiseType;
}
public void setFranchaiseType(String franchaiseType) {
this.franchaiseType = franchaiseType;
}
public Object getFranchiseId() {
return franchiseId;
}
public void setFranchiseId(Object franchiseId) {
this.franchiseId = franchiseId;
}
public Object getFranchisePer() {
return franchisePer;
}
public void setFranchisePer(Object franchisePer) {
this.franchisePer = franchisePer;
}
public Object getFranchiseStatus() {
return franchiseStatus;
}
public void setFranchiseStatus(Object franchiseStatus) {
this.franchiseStatus = franchiseStatus;
}
public String getTransactionPass() {
return transactionPass;
}
public void setTransactionPass(String transactionPass) {
this.transactionPass = transactionPass;
}
public Object getIdProof() {
return idProof;
}
public void setIdProof(Object idProof) {
this.idProof = idProof;
}
public Object getAddressProof() {
return addressProof;
}
public void setAddressProof(Object addressProof) {
this.addressProof = addressProof;
}
public String getSelfVideo() {
return selfVideo;
}
public void setSelfVideo(String selfVideo) {
this.selfVideo = selfVideo;
}
public String getResidentialProof() {
return residentialProof;
}
public void setResidentialProof(String residentialProof) {
this.residentialProof = residentialProof;
}
public Object getBtcAddress() {
return btcAddress;
}
public void setBtcAddress(Object btcAddress) {
this.btcAddress = btcAddress;
}
public Object getPerfectMoney() {
return perfectMoney;
}
public void setPerfectMoney(Object perfectMoney) {
this.perfectMoney = perfectMoney;
}
public String getEmailStatus() {
return emailStatus;
}
public void setEmailStatus(String emailStatus) {
this.emailStatus = emailStatus;
}
public String getEmailVerify() {
return emailVerify;
}
public void setEmailVerify(String emailVerify) {
this.emailVerify = emailVerify;
}
public String getCreatedOn() {
return createdOn;
}
public void setCreatedOn(String createdOn) {
this.createdOn = createdOn;
}
public String getEditedOn() {
return editedOn;
}
public void setEditedOn(String editedOn) {
this.editedOn = editedOn;
}
public String getIsDeleted() {
return isDeleted;
}
public void setIsDeleted(String isDeleted) {
this.isDeleted = isDeleted;
}
}
}
Dashboard.java
private void getUserProfile() {
apiInterface = ApiLinks.getClient().create(APIInterface.class);
ProfilePojo profilePojo = new ProfilePojo("MFL176116");
Call<ProfilePojo> call = apiInterface.getUserProfile(profilePojo);
call.enqueue(new Callback<ProfilePojo>() {
#Override
public void onResponse(#NonNull Call<ProfilePojo> call, #NonNull Response<ProfilePojo> response) {
ProfilePojo profilePojo = response.body();
Toast.makeText(getApplicationContext(), "sucess", Toast.LENGTH_LONG).show();
}
#Override
public void onFailure(#NonNull Call<ProfilePojo> call, #NonNull Throwable t) {
Toast.makeText(getApplicationContext(), t.getMessage(), Toast.LENGTH_LONG).show();
}
});
}
After debugging the code can see Message is success, code =200, but userdata size ==0 please help me to get rid of this error
Check again the way that you are calling the api, even your userid is getting null, probably it's getting null in the user, but the response is 200 bc there was no error, simply no user with that id.
I am just wondering why my getTotal_Score() is null in my model class but I can retrieve it successfully from the database...I have tried both capital Integer and just a normal int, but that doesn't work...I have also tried Long type but I still get a null variable..The other thing that is puzzling me too is that when I use int type instead of long, it doesn't work.... Can you retrieve the numbers as int simple by doing:
int score = (int) snapshop.child("Glen Family Medical Centre").child("Total Score");
I can only get the above to work with long type...
public class Information { // variables have to match in firebase database or it will show null
private String Address;
private String Name;
private String Phone_No;
private String Suburb;
private String State;
private String Postcode;
private String Doctor;
private int Total_Score;
#SuppressWarnings("unused")
public Information() {
}
#SuppressWarnings("unused")
public Information(String address, String name, String phone_No, String suburb, String state, String postcode, String doctor, int total_score) {
Address = address;
Name = name;
Phone_No = phone_No;
Suburb = suburb;
State = state;
Postcode = postcode;
Doctor = doctor;
Total_Score = total_score;
}
public int getTotal_Score() {
return Total_Score;
}
public void setTotal_Score(int total_Score) {
Total_Score = total_Score;
}
public String getAddress() {
return Address;
}
#SuppressWarnings("unused")
public void setAddress(String address) {
Address = address;
}
public String getName() {
return Name;
}
public void setName(String name) {
Name = name;
}
public String getPhone_No() {
return Phone_No;
}
#SuppressWarnings("unused")
public void setPhone_No(String phone_No) {
Phone_No = phone_No;
}
public String getSuburb() {
return Suburb;
}
#SuppressWarnings("unused")
public void setSuburb(String suburb) {
Suburb = suburb;
}
public String getState() {
return State;
}
#SuppressWarnings("unused")
public void setState(String state) {
State = state;
}
public String getPostcode() {
return Postcode;
}
#SuppressWarnings("unused")
public void setPostcode(String postcode) {
Postcode = postcode;
}
public String getDoctor() {
return Doctor;
}
#SuppressWarnings("unused")
public void setDoctor(String doctor) {
Doctor = doctor;
}
}
In my other class, I have used:
Information info = snapshot.getValue(Information.class);
assert info != null;
String txt = "Medical Clinic: " + info.getName() + "Total Score: " + info.getTotal_Score();
list.add(txt);
This api works for inserting and updating but everytim I update the image dissapears so I am trying to say orElse if image not exist set image to existing image any advice pls
#RequestMapping(value = "/updateBank", method = RequestMethod.POST, consumes = "multipart/form-data")
public ResponseEntity<Bank> updateBank(
#RequestPart("bank") #Valid Bank bank,
#RequestPart("file") #Valid Optional<MultipartFile> image) throws IOException {
// routine to update a bank including image
image.ifPresent(pic ->
{
try {
bank.setImage(new Binary(BsonBinarySubType.BINARY, pic.getBytes()));
} catch (IOException e) {
e.printStackTrace();
}
});
Bank result = bankRepository.save(bank);
return ResponseEntity.ok().body(result);
}
#Document(collection = "mst_Bank")
public class Bank {
#Id
private String id;
private String name;
private String address;
private String country;
private String region;
private String city;
private String swiftCode;
private String routeCode;
private Binary flag;
private Binary image;
public Bank(String name, String address, String country, String region, String city, String swiftCode,
String routeCode) {
this.name = name;
this.address = address;
this.country = country;
this.region = region;
this.city = city;
this.swiftCode = swiftCode;
this.routeCode = routeCode;
}
public Bank() {
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getRegion() {
return region;
}
public void setRegion(String region) {
this.region = region;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getSwiftCode() {
return swiftCode;
}
public void setSwiftCode(String swiftCode) {
this.swiftCode = swiftCode;
}
public String getRouteCode() {
return routeCode;
}
public void setRouteCode(String routeCode) {
this.routeCode = routeCode;
}
public Binary getImage() {
return image;
}
public void setImage(Binary image) {
this.image = image;
}
}
/No Point of this
It looks like your post is mostly code; please add some more details.
It looks like your post is mostly code; please add some more details.
It looks like your post is mostly code; please add some more details./
Use Something like this
#RequestMapping(value = "/updateEntity", method = RequestMethod.POST, consumes = "multipart/form-data")
public ResponseEntity<Entity> updateEntity(#RequestPart("entity") #Valid Entity entity, #RequestPart("file") #Valid Optional<MultipartFile> image) throws IOException {
// routine to update a entity including image
byte[] imageData = null;
if (image.isPresent() && image.get() != null)
imageData = image.get().getBytes();
if (imageData == null && entity.getId() != null) {
Optional<Entity> readEntity = entityRepository.findById(entity.getId());
if (readEntity.get() != null)
imageData = readEntity.get().getImage().getData();
}
if (imageData != null) {
entity.setImage(new Binary(BsonBinarySubType.BINARY, imageData));
}
Entity result = entityRepository.save(entity);
return ResponseEntity.ok().body(result);
}
I have a model below which i use to add my data and get it's properties when a user selects an option. Unfortunately i am unable to get the logic right. Kindly help with the best way to set data to a model using an array.
Unfortunately i get the error Data cannot be applied to Data[]
Model
public class Data
{
private String isVerified;
private String providerType;
private String modifiedAt;
private String modifiedBy;
private String provider;
private String id;
private String accountNumber;
private String accountName;
private String createdBy;
private String isDefault;
private String createdAt;
private String userId;
private String providerId;
public String getIsVerified ()
{
return isVerified;
}
public void setIsVerified (String isVerified)
{
this.isVerified = isVerified;
}
public String getProviderType ()
{
return providerType;
}
public void setProviderType (String providerType)
{
this.providerType = providerType;
}
public String getModifiedAt ()
{
return modifiedAt;
}
public void setModifiedAt (String modifiedAt)
{
this.modifiedAt = modifiedAt;
}
public String getModifiedBy ()
{
return modifiedBy;
}
public void setModifiedBy (String modifiedBy)
{
this.modifiedBy = modifiedBy;
}
public String getProvider ()
{
return provider;
}
public void setProvider (String provider)
{
this.provider = provider;
}
public String getId ()
{
return id;
}
public void setId (String id)
{
this.id = id;
}
public String getAccountNumber ()
{
return accountNumber;
}
public void setAccountNumber (String accountNumber)
{
this.accountNumber = accountNumber;
}
public String getAccountName ()
{
return accountName;
}
public void setAccountName (String accountName)
{
this.accountName = accountName;
}
public String getCreatedBy ()
{
return createdBy;
}
public void setCreatedBy (String createdBy)
{
this.createdBy = createdBy;
}
public String getIsDefault ()
{
return isDefault;
}
public void setIsDefault (String isDefault)
{
this.isDefault = isDefault;
}
public String getCreatedAt ()
{
return createdAt;
}
public void setCreatedAt (String createdAt)
{
this.createdAt = createdAt;
}
public String getUserId ()
{
return userId;
}
public void setUserId (String userId)
{
this.userId = userId;
}
public String getProviderId ()
{
return providerId;
}
public void setProviderId (String providerId)
{
this.providerId = providerId;
}
#Override
public String toString()
{
return "ClassPojo [isVerified = "+isVerified+", providerType = "+providerType+", modifiedAt = "+modifiedAt+", modifiedBy = "+modifiedBy+", provider = "+provider+", id = "+id+", accountNumber = "+accountNumber+", accountName = "+accountName+", createdBy = "+createdBy+", isDefault = "+isDefault+", createdAt = "+createdAt+", userId = "+userId+", providerId = "+providerId+"]";
}
}
Below is my method to add data to the model
private void addToWallets(Data walletData) {
Data wallet = new Data();
wallet.setId(walletData.getId());
wallet.setAccountNumber(walletData.getAccountNumber());
wallets.add(wallet);
}
I add the response from the server to my method that i created to add data to the model:
if (response.isSuccess()){
loading.dismiss();
Data[] wallets = response.body().getData();
addToWallets(wallets);
}
An array of Data can't be converted to a single Data object.
I suppose that this is what you want:
Data[] wallets = response.body().getData();
for (Data wallet : wallets) {
addToWallets(wallet);
}
I feel my app runs slow. I use Java for my server, so except java itself,the first reason of slow run, I think, is the account of database access. Hibernate could search all attribute associate with the entity which you are using, so I think it may send a lot of SQL language when finding one entity. If there's a large concurrent happening ,the trouble will happen.
#Component("user")
#Entity
#Table(name="users")
public class User implements Serializable{
#Id
#GenericGenerator(strategy="assigned",name="idGenerator")
#GeneratedValue(generator="idGenerator")
private String client_id;
#Column(name="username")
private String username;
#Column(name="password")
private String password;
#Column(name="email")
private String email;
#Column(name="phone")
private String phone;
#Column(name="sex")
private String sex;
#Column(name="birth")
private String birth;
#Column(name="status")
public String status;
#Column(name="isonline")
private String isonline;
#Column(name="province")
private String province;
#Column(name="city")
private String city;
#ManyToOne()
#JoinColumn(name="channel_id")
private Channel channel;
#Temporal(TemporalType.TIMESTAMP)
#Column(name="created_at",updatable=true)
private Date created_at = new Date();
#Column(name="last_login_at")
private Date last_login_at;
#ManyToMany()
#JoinTable(name = "users_labels",
joinColumns = #JoinColumn(name = "client_id"),
inverseJoinColumns = #JoinColumn(name = "label_name"))
#LazyCollection(LazyCollectionOption.FALSE)
private Set<Label> labellist;
#ManyToOne()
#JoinTable(name = "user_topics",
joinColumns = #JoinColumn(name = "client_id"),
inverseJoinColumns = #JoinColumn(name = "huanxin_group_id"))
private Topic topic;
#ManyToMany()
#JoinTable(name="friends",
joinColumns=#JoinColumn(name="client_id"),
inverseJoinColumns=#JoinColumn(name="friend_id"))
#LazyCollection(LazyCollectionOption.FALSE)
private Set<User> friends;
#OneToMany(mappedBy="user")
private Set<FeedBack> feedbacks;
#ManyToMany()
#JoinTable(name="blacklist",
joinColumns=#JoinColumn(name="client_id"),
inverseJoinColumns=#JoinColumn(name="blocker_id"))
#LazyCollection(LazyCollectionOption.FALSE)
private Set<User> blacklist;
public Topic getTopic() {
return topic;
}
public void setTopic(Topic topic) {
this.topic = topic;
}
public Set<Label> getLabellist() {
return labellist;
}
public void setLabellist(Set<Label> labellist) {
this.labellist = labellist;
}
public String getClient_id() {
return client_id;
}
public void setClient_id(String client_id) {
this.client_id = client_id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public String getBirth() {
return birth;
}
public void setBirth(String birth) {
this.birth = birth;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getIsonline() {
return isonline;
}
public void setIsonline(String isonline) {
this.isonline = isonline;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getProvince() {
return province;
}
public void setProvince(String province) {
this.province = province;
}
public Channel getChannel() {
return channel;
}
public void setChannel(Channel channel) {
this.channel = channel;
}
public Date getCreated_at() {
return created_at;
}
public void setCreated_at(Date created_at) {
this.created_at = created_at;
}
public Date getLast_login_at() {
return last_login_at;
}
public void setLast_login_at(Date last_login_at) {
this.last_login_at = last_login_at;
}
public Set<User> getFriends() {
return friends;
}
public void setFriends(Set<User> friends) {
this.friends = friends;
}
public Set<FeedBack> getFeedbacks() {
return feedbacks;
}
public void setFeedbacks(Set<FeedBack> feedbacks) {
this.feedbacks = feedbacks;
}
public Set<User> getBlacklist() {
return blacklist;
}
public void setBlacklist(Set<User> blacklist) {
this.blacklist = blacklist;
}
#Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result
+ ((client_id == null) ? 0 : client_id.hashCode());
return result;
}
#Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
User other = (User) obj;
if (client_id == null) {
if (other.client_id != null)
return false;
} else if (!client_id.equals(other.client_id))
return false;
return true;
}
#Override
public String toString() {
return "User [client_id=" + client_id + ", username=" + username
+ ", labellist=" + labellist+ "]";
}
}
Just like this, User contains Topic, Label or other Entity in future. So I think that is not possible to remove this association. How could I improve my database access to improve access speed?
Another reason influncing the app speed may be my algorithm. I use bubble sort, selection sort, and quick sort. Each sort seems to cost little time on little data. But what if the concurrent occurs? 300 users may cost only 20 msec but 300 000 I couldn't imagine.
Here is my sort code:
private static List<Map<String,Object>> sortInteger(List<Map<String,Object>> list){
int index = 0;
int max = 0;
Map<String,Object> temp = new HashMap<String, Object>();
for(int i=0;i<list.size();i++){
for(int j=0;j<list.size()-i-1;j++){
Map<String,Object> pre = (Map<String, Object>) list.get(j);
Map<String,Object> next = (Map<String, Object>) list.get(j+1);
if((Integer)pre.get("sortnum")<(Integer)next.get("sortnum")){
temp = pre;
list.set(j, next);
list.set(j+1,pre);
}
}
}
return list;
}
So in terms of above, I need some suggestion to solve my question,either theory or code.