jaimin prajapati
jaimin prajapati

Reputation: 43

What is the difference between sql-query and query in hibernate mapping file?

What is the difference between below syntax? Will it make any difference?

<hibernate-mapping>
<sql-query name="xyz">
<!--- SQL Query -->
</sql-query>
</hibernate-mapping>

&

<hibernate-mapping>
<query name="xyz">
<!--- SQL Query -->
</query>
</hibernate-mapping>

Upvotes: 1

Views: 2937

Answers (1)

Akshay
Akshay

Reputation: 1161

The first query is an SQL query so you need to put an pure SQL query there. The second is Query so you need to put a Hibernate query there.

The SQL query is the query you use in MYSQL console.Eg:"SELECT * FROM TABLENAME" The HQL(Hibernate Query Language) Eg: "FROM CLASSNAME" CLASSNAME is the POJO/DAO object that you have mapped with your database. reach out if you need more Info

Upvotes: 1

Related Questions