可以将两个属性与JPA自定义查询进行比较吗?
Registration.java:
=if(or(isna(index('SSI Tracker'!$A:$F,small(match(F25,'SSI Tracker'!$D:$D,0),2),2)),index('SSI Tracker'!$A:$F,small(match(F25,'SSI Tracker'!$D:$D,0),2),2)=""),"",concatenate(index('SSI Tracker'!$A:$F,small(match(F25,'SSI Tracker'!$D:$D,0),2),1)," / ",index('SSI Tracker'!$A:$F,small(match(F25,'SSI Tracker'!$D:$D,0),2),2)))
Rate.java:
@Entity
public class Registration implements Serializable {
@Id
@GeneratedValue(generator = "uuid")
private UUID uuid;
@ManyToOne(targetEntity=Entry.class)
private Entry entry;
@ManyToMany(targetEntity=Rate.class,fetch = FetchType.EAGER)
private List<Rate> rate;
@ManyToMany(fetch = FetchType.EAGER)
private List<Planning> planning;
}
Planning.java:
@Entity
public class Rate implements Serializable {
@Id
@GeneratedValue(generator = "uuid")
private UUID uuid;
@ManyToOne
private Activity activity;
}
我只会检索rate.activity.id = planning.activity.id,例如:
@Entity
public class Planning implements Serializable {
@Id
@GeneratedValue(generator = "uuid")
private UUID uuid;
@OneToOne
private Location location;
@OneToOne(fetch = FetchType.EAGER)
private Coach coach;
@OneToOne
private Activity activity;
由于
答案 0 :(得分:2)
您可以拥有一个JPA查询,而不是拥有一个长方法名称。希望这会有所帮助。
@Query("select * FROM Registration REG,Entry E, Rate R,Planning P WHERE REG.id = :id and R.activity=P.activity ORDER BY E.lastname")
public List<Registration> <MethodName>(@Param("id") String registrationid);
答案 1 :(得分:0)
我已针对此解决方案进行了更改,但我认为这不是一个好方法(其中rateActivity和planningActivity必须具有相同的ID)
public interface RegistrationDao extends CrudRepository<Registration, UUID> {
Iterable<Registration> findByPlanningAndRateActivityEqualsAndPlanningActivityEqualsOrderByEntryLastnameAsc(Planning planning,Activity rateActivity,Activity planningActivity);
}