I am a bit confused about how the value passing from getter and setters.
Here I have 2 class
Seller and contract that I wanna pass seller.symbol value into Contract
seller
import org.bson.types.ObjectId;
import org.mongodb.morphia.annotations.Entity;
import org.mongodb.morphia.annotations.Id;
import java.util.Date;
import java.util.List;
@Entity(value = "S", noClassnameStored = true)
public class Seller {
@Id
private ObjectId id;
private String symbol;
private String clearingVenue;
private String description;
private String address;
private String city;
private String term;
private String state;
private String zipCode;
private String country;
private boolean showUser;
...Getter and Setters
Contract
package dao.contract;
import dao.seller.Seller;
import org.bson.types.ObjectId;
import org.mongodb.morphia.annotations.Entity;
import org.mongodb.morphia.annotations.Id;
import requests.CreateSellerRequest;
import requests.UpdateSellerRequest;
import java.util.Date;
import java.util.List;
@Entity(value = "contracts", noClassnameStored = true)
public class Contract {
@Id
private ObjectId id;
private String symbol;
private String description;
private int size;
private String delivery;
private String contractName;
private double volumeInc;
private String facility;
private boolean showUser;
private String seller;
private Seller sellers;
What is the best approach to do this ? Should I call getter in Contract like "seller object.symbol" I wanna pass the symbol value into Contract: String seller. what is the best approach here to connect value from 2 tables?
I need some suggestion. not sure how to approach this issue.
Thanks
the best approach is to use getter setter methods for private data members. in Contract class just write . hope it will help you.
String symbols=sellerObject.getSymbol();
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.