Saturday, March 9, 2013

Hibernate Course: Section: 10 - Hibernate Query Language and Java Persistence Query Language v70 - v77

Writing Queries
you can write a query in hibernate like this:



in hibernate you can create like this



Expressions and Operators
in hibernate


just one thing when you use "t" in the example, you are using an object from transaction so you can write t.amount or go to another level for example t.amount.SOMETHING

in JPA



Parameters


another example



Joins



as you can see we have a normal join here

we have another thing which is called implecit join


as you can see there is no join there, however when you say select t.account, hibernate knows that we should do this join.

ALWAYSE USE THE EXPLICIT JOIN

Functions
sure you can use functions in your query


Named Query
sometimes you find yourself writing the same query multiple times, thats why we have named query, you define the query one time and then use it


then you can use it

Lazy Loading
you know that for relations we have eager or lazy fetching, to set the value and say if it is lazy or eager


No comments:

Post a Comment