java - createSQLQuery with parameter in Hibernate -
i'm trying run this:
.. string modeltablename = (model == tablemodeltype.ring) ? "ring_players" : "tourny_players"; list<object[]> results = dbs.createsqlquery("select group_level, count(group_level) :modeltablename game_id=:gameid group group_level") .addscalar("group_level", hibernate.integer) .addscalar("count(group_level)", hibernate.long) .setstring("modeltablename", getmodeltablename()) .setinteger("gameid", getgameid()) .list();
it gives exception:
caused by: java.sql.sqlexception: ora-00903: invalid table name
if write "ring_players" instead of ":tablemodelname" works!
what doing wrong parameter?
thank you.
according answer, can not inject table name: table name parameter in hql
you may have construct as:
list<object[]> results = dbs.createsqlquery("select group_level, count(group_level) " + getmodeltablename() + " game_id=:gameid group group_level") .addscalar("group_level", hibernate.integer) .addscalar("count(group_level)", hibernate.long) .setinteger("gameid", getgameid()) .list();
Comments
Post a Comment