Hibernate SQLQuery bypasses hibernate session cache

后端 未结 2 1839
心在旅途
心在旅途 2020-12-18 10:32

I\'m \"transactionalizing\" some extensive database manipulation and I came across this issue where if I run sql queries through hibernate but not using the MQL approach, th

2条回答
  •  长情又很酷
    2020-12-18 10:38

    Your question is confusing, but I assume you are saying that Hibernate is not looking for entities in the Session cache when you are performing Native queries.

    SQL Query, or Native Query, is a query which Hibernate just relays to the database. Hibernate won't parse the query, and it won't parse the results. Hibernate will, though, let you handle the results, to convert the columns into properties of a class. That said, it sounds quite natural that Native Queries would bypass the Session cache. That's because Hibernate doesn't knows anything about your query, nor about the "results" of this query (which are not objects at that point).

提交回复
热议问题