我正在尝试在 java 接口中继承以下参数(来自 Spring Data JPA 的示例,但问题通常是关于注释的参数):
public interface ItemRepository<T extends Item> extends BaseRepository<T> {
public final String type = null;
@Query("select distinct i from " + type + " i " +
"join i.tags t " +
"join fetch i.locale where t = ?1")
public List<T> findByTag(Tag t);
}
这样在继承的接口中我就可以:
public interface EventRepository extends ItemRepository<Event> {
public final static String type = "Event";
}
但不幸的是,变量“type”的字符串值关联到变量的时间太晚了,所以在创建注解时,该值仍然为空。我可以强制编译器关联子接口中的变量吗?
谢谢