我有如下的 Java 实体
@Entity
@Table(name = "user", schema = "xxxx")
public class User extends AuditableBase<Long> {
/** The Constant serialVersionUID. */
private static final long serialVersionUID = -5827659402853250569L;
public static final String FTL = "FTL";
/** The refer number. */
@Column(name = "reference_number")
private String referenceNumber;
/** The customer id. */
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "customer_id")
@Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED)
private Customer customer;
/** The load Notes. */
@OneToMany(cascade = CascadeType.ALL, mappedBy = "load")
@JsonBackReference
private Set<Notes> notes = new HashSet<>();
/** The customer location. */
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "customer_location_id")
@Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED)
private CustomerLocation customerLocation;
/** The invoice number. */
@Column(name = "invoice_number")
private String invoiceNumber;
// Lot going
/**
* Instantiates a new User.
*/
public User() {
super();
}
/**
* Instantiates a new User.
*
* @param id
* the id
*/
public User(Long id) {
super(id);
}
}
我在实体内部有很多孩子,我从 DAO 调用中获取对象
User user = userRepository.findById(userId);
现在我想根据一些引用 Map 的 if 条件获取一些用户详细信息。
Map<Integer, String> cc = new HashMap<Integer, String>();
cc.put(1, "getCustomer()");
cc.put(2, "getNotes()");
cc.put(3, "getCustomerLocation()");
cc.put(4, "getReferenceNumber()");
for (Entry<Integer, String> map : cc.entrySet()) {
user.map.getvalue();
}
我需要创建一个通用方法来根据地图获取用户对象。
我怎样才能做到这一点。
牧羊人nacy
相关分类