Posts

Showing posts from July, 2018

Hibernate Named Queries With Annotation- Comming Soon

Hibernate Named Queries With XML- Comming Soon

Component Mapping With Annotation

When we want to store one class object as value to another class object then we have to use component mapping For Component mapping we have two annotations. 1. Embedable 2.Embeded A class whose object we want to store like a value of another class object should be annotated with ======> @Embedable To the reference variable of embedable class we need to as ===> @Embeded annotation  =============================================== @Embeddable public class Address {     int hno;     String city; } ================================================ @Entity @Table public class Student {     @Id     int id;     @Column     String  name;     @Embedded Address address; ===============================================

Component Mapping In Hibernate with XML

If we want to store one class object at a value of another class object, then we use component mapping. To use Component mapping the two classes should  have 'has-a' relation between them. In hbm file to map a Component to a table of a database then we have <Component> tag. Ex : public class Employee{       int id; String name; Address address;                   } class Address{ int hno; String street; String city; } hbm file: ====================================== <hibernate-mapping>     <class name="hibernate1.Student" table="finalst">         <id name="id"></id>         <property name="name"></property>         <component name="address">             <property name="hno"/>   <property name="street"/>             <property name="city"/>         </component>            </class>  </hibernate-m

Dialect In Hibernate

Dialect are used to provide information to hibernate about in which SQL command it translate your HQL and Criteria command because SQL is database dependent language and changes from database to database … so to convert our HQL or criteria into a suitable SQL based on database dialect.

Criteria API- Hibernate Notes

To perform bulk select operation we use this criteria API. Criteria API means we use criteria interface and we call methods of criteria interface  for reading entities from the database. Criteria API can be used only for select operation, we can not perform non select operation using criteria. In criteria API , there will be less burden  on programmer because query tuning will be taken care by hibernate only. To select entities from database using criteria API hen we need criteria object. We can create criteria object  by calling createCriteria method of session interface ex:              List list=session.createCriteria(Student.class); Using criteria API we can read entities from database in following ways 1. If we want to read full entities form database by without applying any conditions then we need to directly call list method on criteria object.                            List list=crit.list(); =============================================== 2. If we wan