When to add a scalar to a named query

When do I need to add a scalar to a named query? For instance:

<return-scalar column="colName" type="java.lang.String" /> 

Sometimes they do not seem to be needed, and sometimes, without a scalar, the request will throw an exception.

+3
source share
1 answer

Let me share some materials.

  • If your query select * from the table , setScalar can be used to dynamically restrict the no column.

  • If you use a scalar, the query will not use ResultSetMetadata b> to find this type and will use a faster and more efficient type.

  • java.sql.Types ResultSetMetaData, Hibernate, . , registerHibernateType .

+2

Source: https://habr.com/ru/post/1796373/


All Articles