我正在尝试使用Query方法在Repository中执行以下Query。我想要唯一的Slocation,结果应该是JSON
格式(键,值)
这是我的代码
@Repository
public interface AccountRepository extends JpaRepository<Account, Integer>, QueryDslPredicateExecutor<Account> {
// Load location
@Query("select new map (distinct(a.slocation) as slocation) from Account a where a.slocation !=null")
Set<Account> findSlocation();
错误
Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: distinct near line 1, column 17 [select new map (distinct(a.slocation) as slocation) from com.spacestudy.model.Account a where a.slocation !=null]
任何人都可以告诉我如何解决这个错误吗?
答案 0 :(得分:1)
您可以使用:
const {AppServerModuleNgFactory, LAZY_MODULE_MAP} = require('./dist/server/main.bundle');
app.engine('html', ngExpressEngine({
bootstrap: AppServerModuleNgFactory,
providers: [
provideModuleMap(LAZY_MODULE_MAP)
]
}));
答案 1 :(得分:1)
我还有一个解决方案,因为我删除了不同的内容并添加了Set
而不是List
@Query("select new map (a.slocation as slocation) from AccountModel a where a.slocation !=null")
Set<AccountModel> findBySlocation();