Submitted by heartin on Wed, 08/28/2013 - 10:09
We can have queries saved with a name and later we can retrieve them simply using that name. We use @NamedQuery annotation to declare a named query. We can also have a named query for native sql. For native SQL we use the annotation @NamedNativeQuery annotation. This is one of the important advantages of having a named query: you can write native SQL. You can retrieve a Query object from a saved query name (hql and native named query) using session.getNamedQuery method.
Submitted by heartin on Wed, 08/28/2013 - 09:02
Parameter binding is the process of binding a Java variable with an HQL statement. Using Parameter binding and not string concatenation for HQL statement creation will also guard against attacks like SQL injection.
Submitted by heartin on Tue, 08/27/2013 - 11:53
Hibernate provides a query language called Hibernate Query Language (HQL). HQL is similar to SQL in syntax, but HQL queries are written against Hibernate's entity objects, not database tables. Hibernate also provide Criteria Queries as an object-oriented alternative to HQL. Criteria Query is used to modify the objects and provide the restriction for the objects. Here we will see the basics of HQL and later in another tutorial we will see criteria queries.
Submitted by heartin on Sat, 08/24/2013 - 13:04
Here we will see all the CRUD operations, and also object states and transitions in hibernate. CRUD operations are Create(save), Read(select), Update(update) and Delete(delete). We will see object states in hibernate such a new/transient, attached/persistent and detached. We will also see how update is called automatically (without an explicit update call) when the object is attached to a session.
Submitted by heartin on Wed, 08/21/2013 - 20:49
Hibernate uses some strategies for saving an inheritance hierarchy of classes created in Java to the databases like SINGLE_TABLE, TABLE_PER_CLASS and JOINED. We use @Inheritance annotation over the entity class to specify the inheritance strategy. We specify the inheritance strategy by assigning a strategy from the InheritanceType enumeration to the strategy parameter of the @Inheritance annotation. Strategies defined in the InheritanceType enumeration are InheritanceType.SINGLE_TABLE, InheritanceType.TABLE_PER_CLASS and InheritanceType.JOINED.
Pages