我有这样的结构-
@Entity
@Table("transaction")
public class TransactionBean{
@Id
Long txnId;
//other stuff
}
@Entity
@Table("someclass")
public class SomeClass{
@Id
TransactionBean transactionBean;
//other stuff
}
以及每个的存储库 -
public interface TransactionRepo extends CrudRepository<TransactionBean, Long){
//some stuff
}
public interface SomeClassRepo extends CrudRepository<SomeClass, TransactionBean){
//some stuff
}
现在我需要找到一条SomeClass
使用记录txnId
。是否有如下图所示的单行功能,还是我需要先获取一个TransactionBean
然后使用它来搜索SomeClass
。
TransactionBean txnBean;
//some stuff done with it
SomeClassRepo someClassRepo;
//I need some function like this
SomeClass someClass = someCLassRepo.findBySOMETHING(txnBean.getTxnId());