Java ORM如何映射到接口?

Java ORM如何映射到接口?,java,spring,spring-data-jpa,Java,Spring,Spring Data Jpa,这些天我在学习JPA预测 有件奇怪的事我不明白 下面是我的问题 Spring数据JPA存储库 public interface PersonRepository extends JpaRepository<Person, Serializable> { Collection<NameAgeOnly> findByAgeGreaterThan(int age); } 安置试验 public class RepositoryTest { List<Count

这些天我在学习JPA预测
有件奇怪的事我不明白

下面是我的问题

Spring数据JPA存储库

public interface PersonRepository extends JpaRepository<Person, Serializable> {

  Collection<NameAgeOnly> findByAgeGreaterThan(int age);
}
安置试验

public class RepositoryTest {
  List<CountByAddress> countByAddressList = personRepository.getCityNameAndPersonCount();
  debug.log(countByAddressList.get(0).getName());
}
公共类RepositoryTest{
List countByAddressList=personRepository.getCityNameAndPersonCount();
log(countByAddressList.get(0.getName());
}
countByAddressList.get(0).getName如何工作?没有只实现名称的类

接口是否有默认类? 谁能解释如何将ORM映射到接口而不是类

谢谢:)

解释如下:

查询执行引擎在运行时为返回的每个元素创建该接口的代理实例,并将对公开方法的调用转发给目标对象

解释如下:

查询执行引擎在运行时为返回的每个元素创建该接口的代理实例,并将对公开方法的调用转发给目标对象


谢谢:)我已经看过了。我想知道查询引擎如何强制将对公开方法的调用转发到目标对象,在哪里可以找到它?我能看看代理实例吗?不知道你说的是什么意思。spring数据是开源的,因此您可以浏览源代码。您还可以打印返回的实例,或使用调试器检查它们。你也可以在谷歌上搜索“什么是动态代理”。谢谢:)我已经读过了。我想知道查询引擎如何强制将对公开方法的调用转发到目标对象,在哪里可以找到它?我能看看代理实例吗?不知道你说的是什么意思。spring数据是开源的,因此您可以浏览源代码。您还可以打印返回的实例,或使用调试器检查它们。你也可以在谷歌上搜索“什么是动态代理”。
public class RepositoryTest {
  List<CountByAddress> countByAddressList = personRepository.getCityNameAndPersonCount();
  debug.log(countByAddressList.get(0).getName());
}