spring data jpa查询有关问题

spring data jpa查询问题

public class FinancialLoanInfo implements java.io.Serializable {
 
    // Fields
 
    /**
     * 
     */
    private static final long serialVersionUID = -5163416181325490447L;
    private BigDecimal loanId;
    private FinancialUsers userId;
        //.....
 
}

//现在FinancialLoanInfo 对象里有userId对象,我在查询FinancialLoanInfo 结果集的时候,只是要userId而不想要多发一次sql去查询出整个user对象。有木有什么办法处理


------解决方案--------------------
用@Formula注解里面直接写上sql语句hibernate就会把这个sql拼接上去一次性查数据库
------解决方案--------------------
引用:
引用:“只是要userId而不想要多发一次sql去查询出整个user对象”

userId不是个FinancialUsers对象么。。
那整个user对象又是什么意思

现在FinancialLoanInfo对象里面要userId就是要关联private FinancialUsers userId;对象
但是实际上数据库是一个……


看着晕。。
你关联关系怎么设的?
搞个延迟加载不行么?

@OneToMany(fetch = FetchType.LAZY, cascade = { CascadeType.ALL })