0% found this document useful (0 votes)
32 views2 pages

Assignment 8 - AST

The document describes examples of Hibernate configuration files and clauses in the Hibernate Query Language (HQL). It provides sample XML for a Hibernate configuration file and mapping file. It also explains the SELECT, WHERE, and UPDATE clauses in HQL, describing their syntax and usage for querying and updating data through Hibernate.

Uploaded by

Nikhil Patil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views2 pages

Assignment 8 - AST

The document describes examples of Hibernate configuration files and clauses in the Hibernate Query Language (HQL). It provides sample XML for a Hibernate configuration file and mapping file. It also explains the SELECT, WHERE, and UPDATE clauses in HQL, describing their syntax and usage for querying and updating data through Hibernate.

Uploaded by

Nikhil Patil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Assignment 8

1. Write examples of following files.


a) Hibernate configuration xml file
b) Hibernate Mapping Xml
Ans:
a) XML file
<hibernate-mapping>
<class name="POJO class name" table="table name in database">
<id name="variable name" column="column name in database"
type="java/hibernate type" />
<property name="variable1 name" column="column name in database"
type="java/hibernate type" />
<property name="variable2 name" column="column name in database"
type="java/hibernate type" />
</class>
</hibernate-mapping>

b) Mapping XML

<hibernate-mapping>

<class name="POJO class name" table="table name in database">


<id name="variable name" column="column name in database"
type="java/hibernate type" />
<property name="variable1 name" column="column name in database"
type="java/hibernate type" />
<property name="variable2 name" column="column name in database"
type="java/hibernate type" />
</class>

</hibernate-mapping>
2. Explain following clause in HQL (Hibernate Query Language.)
a. Select
b. where
c. update
Ans:
a) An HQL SELECT is used to query the database for classes and their
properties. Here’s the syntax of the SELECT statement:
[SELECT [DISTINCT] property [, ...]]
FROM path [[AS] alias] [, ...] [FETCH ALL PROPERTIES]
WHERE logicalExpression
GROUP BY property [, ...]
HAVING logicalExpression
ORDER BY property [ASC | DESC] [, ...]

b) Where Clause is used to limit the results returned from database. It can be
used with aliases and if the aliases are not present in the Query, the
properties can be referred by name. For example:
from UserDetails user where user.userId = 3

c) UPDATE alters the details of existing objects in the database. In-memory


entities, managed or not, will not be updated to reflect changes resulting
from issuing UPDATE statements. Here’s the syntax of the UPDATE
statement:
UPDATE [VERSIONED]
[FROM] path [[AS] alias] [, ...]
SET property = value [, ...]
[WHERE logicalExpression]

You might also like