Created
August 13, 2018 09:07
-
-
Save smallsong/e7e38810d3ef299b968bed55ebec924b to your computer and use it in GitHub Desktop.
直接把查询结果输出位Map
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public List<?> findAllGameStateByUnitIdAndUserId(int unitId, int userId) { | |
Query query = entityManager.createNativeQuery("SELECT b.*, IF(c.id > 0, 1, 0) as is_finish FROM `wx_unit_game` a" + | |
" left join `wx_catalog` b on a.game_id = b.id" + | |
" left join `wx_unit_game_progress` c on c.game_id = a.game_id and c.user_id = :userId" + | |
" WHERE a.unit_id = :unitId and b.game_is_lock = 1"); | |
query.unwrap(SQLQuery.class).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP); | |
query.setParameter("userId", userId); | |
query.setParameter("unitId", unitId); | |
List result = query.getResultList(); | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment