Powered by Blogger.
Showing posts with label Hibernate. Show all posts
Showing posts with label Hibernate. Show all posts

Hibernate notes by Sekhar sir from Naresh i Technologies

>> Thursday, October 9, 2014

Hibernate notes (material) by Mr.Sekhar sir is given in PDF file format to download. I have given many pdf materials of Sekhar sir like Spring , WebServices, and XML notes. He covered all the topics in Spring with different modules. Currently Sekhar sir is working with Sathya Technologies. In this Hibernate class notes he covered all the Hibernate interview Questions and differences between load and get methods and about lazy loading. I am sure that you can easily understand the hibernate class notes.
Hibernate notes by Mr.Sekhar -JavabynataraJ

Read more..

Spring and Hibernate by Santosh from Santosh Technologies

>> Monday, March 17, 2014

Santosh Kumar K has been associated with training and development on java and its related Technologies since 2001.
Spring and Hibernate by Santosh_JavabynataraJ

He has conducted training programs for the Corporate Sector involved in enterprise application developments on the J2EE technologies and other frameworks like Struts,JSF,Spring and Hibernate. His seminars and workshops are well known for their high quality content backed by his unique style of delivery.

Read more..

Hibernate Interview Questions and Answers - 5

>> Saturday, June 18, 2011

41) What is the difference between sorted and ordered collection in hibernate?


A) sorted collection vs. order collection
sorted collection :-
A sorted collection is sorting a collection by utilizing the sorting features provided by the Java collections framework. The sorting occurs in the memory of JVM which running Hibernate, after the data being read from database using java comparator.
If your collection is not large, it will be more efficient way to sort it.
order collection :-
Order collection is sorting a collection by specifying the order-by clause for sorting this collection when retrieval.
If your collection is very large, it will be more efficient way to sort it .

Read more..

Hibernate Interview Questions and Answers - 4

>> Friday, June 17, 2011

31) What does it mean to be inverse?

A) It informs hibernate to ignore that end of the relationship. If the one–to–many was marked as inverse, hibernate would create a child–>parent relationship (child.getParent).

32) What do you mean by Named – SQL query?

A) Named SQL queries are defined in the mapping xml document and called wherever required.

Example:

SELECT emp.EMP_ID AS {emp.empid},
emp.EMP_ADDRESS AS {emp.address},
emp.EMP_NAME AS {emp.name}
FROM Employee EMP WHERE emp.NAME LIKE :name

Invoke Named Query :
List people = session.getNamedQuery(“empdetails”).setString(“TomBrady”, name).setMaxResults(50).list();

Read more..

Hibernate Interview Questions and Answers - 3

>> Thursday, June 16, 2011

21) What role does the Session interface play in Hibernate?

A) The Session interface is the primary interface used by Hibernate applications. It is a single-threaded, short-lived object representing a conversation between the application and the persistent store. It allows you to create query objects to retrieve persistent objects.

Session session = sessionFactory.openSession( );

Session interface role:
* Wraps a JDBC connection
* Factory for Transaction
* Holds a mandatory (first-level) cache of persistent objects, used when navigating the object graph or looking up objects by identifier

Read more..

Hibernate Configuration file (hibernate.cfg.xml) in Detail

>> Wednesday, June 15, 2011

Hibernate Configuration file for SQLyog.

Before configuring the properties of hibernate.cfg.xml we should mention the xml schema definitions of hibernate-configurations.The dtd defines the version and everything which is licensed.

To configure with database to our application we should give all the properties related to our database.The given properties of hibernate-configuration.

hibernate.connection.driver_class
hibernate.connection.url
hibernate.connection.username
connection.password
connection.pool_size
hibernate.dialect
show_sql
hibernate.hbm2ddl.auto


Read more..

Hibernate Interview Questions and Answers - 2

11) Explain about mapping files in Hibernate?

Mapping files forms the core of any database mapping tools. These files contain field to field mapping, usually this mapping occurs between classes and attributes. After mapping files they can be persist to the database. Tags can be used to indicate the presence of a primary key.

12) What is the effect when a transient mapped object is passed onto a Sessions save?


When a session.save( ) is passed to a transient mapped object it makes the method to become more persistent. Garbage collection and termination of the Java virtual machine stays as long as it is deleted explicitly. It may head back to its transient state.

13) Explain about version field?

Application level data integrity constants are important if you are making changes to offline information which is again backed by database. Higher level locking or versioning protocol is required to support them. Version field usage comes at this stage but the design and implementation process is left to the developer.

Read more..

Hibernate Interview Questions and Answers - 1

>> Tuesday, June 14, 2011

1) Explain about Hibernate?
Hibernate Interview Questions_JavabynataraJ
Hibernate solves problems such as Object Relational impedance mismatch, etc. It is commonly used for object and query service. It helps data base developers develop classes which include inheritance, association, composition and polymorphism. A developer or user can express queries either in HQL or SQL.

2) Explain about the primary feature of Hibernate?

Primary feature of hibernate is to java classes to database tables. Data query and retrieval is also possible with Hibernate. Application portability is a key feature in Hibernate it allows developers to port applications to almost all SQL databases.

Read more..

Simple Hibernate Example on Inserting Employee details using MySql

>> Wednesday, May 25, 2011

Hibernate is a solution for object relational mapping and a persistence management solution or persistent layer. This is probably not understandable for anybody learning Hibernate.

What you can imagine is probably that you have your application with some functions (business logic) and you want to save data in a database. When you use Java all the business logic normally works with objects of different class types. Your database tables are not at all objects.

Hibernate provides a solution to map database tables to a class. It copies the database data to a class. In the other direction it supports to save objects to the database. In this process the object is transformed to one or more tables.

Read more..

Hibernate Caching Techniques

>> Wednesday, May 18, 2011

Caching is a Temporary memory or buffer which resides at client side and stores the results sent by server. When client generates same request for multiple number of times, the first request generated results will be stored in cache and this result will be used across the multiple requests. This reduces the round trips between the client and server. Since the result will be collected from cache that is available at client side.
Hibernate supports for 2 levels of cache:
  1. Level one cache
  2. Level two cache.

Read more..

What is lazy loading in Hibernate?

>> Friday, March 25, 2011

What is lazy loading in Hibernate_JavabynataraJLazy setting decides whether to load child objects while loading the Parent Object.You need to do this setting respective hibernate mapping file of the parent class.lazy = true (means not to load child)By default the lazy loading of the child objects is true. This make sure that the child objects are not loaded unless they are explicitly invoked in the application by calling getChild() method on parent.In this case hibernate issues a fresh database call to load the child when getChild() is actully called on the Parent object.But in some cases you do need to load the child objects when parent is loaded. Just make the lazy=false and hibernate will load the child when parent is loaded from the database.

Read more..

Difference between load( ) vs get( ) in Hibernate

>> Wednesday, March 23, 2011

The following Hibernate code snippet retrieves a User object from the database:

load()
--------------
1). Only use the load()method if you are sure that the object exists.
2). load() method will throw an exception if the unique id is not found in the database.
3). load() just returns a proxy by default and database won’t be hit until the proxy is first invoked.

Read more..

Disadvantages of Hibernate

>> Sunday, March 20, 2011

The main disadvantages of Hibernate is given in detail.

1) Steep learning curve.

2) Use of Hibernate is an overhead for the applications which are :

simple and use one database that never change
need to put data to database tables, no further SQL queries
there are no objects which are mapped to two different tables
Hibernate increases extra layers and complexity. So for these types of applications JDBC is the best choice.

3) Support for Hibernate on Internet is not sufficient.

Read more..

JDBC Vs Hibernate

>> Saturday, March 19, 2011


Why is Hibernate better than JDBC

1)   Relational Persistence for JAVA

Working with both Object-Oriented software and Relational Database is complicated task with JDBC because there is mismatch between how data is represented in objects versus relational database. So with JDBC, developer has to write code to map an object model's data representation to a relational data model and its corresponding database schema. Hibernate is flexible and powerful ORM solution to map Java classes to database tables. Hibernate itself takes care of this mapping using XML files so developer does not need to write code for this.

2)   Transparent Persistence

The automatic mapping of Java objects with database tables and vice versa is called Transparent Persistence. Hibernate provides transparent persistence and developer does not need to write code explicitly to map database tables tuples to application objects during interaction with RDBMS. With JDBC this conversion is to be taken care of by the developer manually with lines of code.

Read more..

Hibernate communication with RDBMS

General steps:

1. Load the Hibernate configuration file and create configuration object. It will automatically load all hbm           mapping files.
2. Create session factory from configuration object
3. Get one session from this session factory.
4. Create HQL query.
5. Execute query to get list containing Java objects.

Example: Retrieve list of employees from Employee table using Hibernate. /* Load the hibernate configuration file */

Configuration cfg = new Configuration(); cfg.configure(CONFIG_FILE_LOCATION);

/* Create the session factory */

SessionFactory sessionFactory = cfg.buildSessionFactory();

/* Retrieve the session */

Session session = sessionFactory.openSession();

/* create query */

Query query = session.createQuery("from  EmployeeBean”);

/* execute query and get result in form of Java objects */ List finalList = query.list();

EmployeeBean.hbm.xml File


"-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">




















Read more..

4. Introduction to Hibernate

Hibernate is an Object-Relational Mapping (ORM) solution for JAVA. It is a powerful, high performance object/relational persistence and query service. It allows us to develop persistent classes following object-oriented idiom – including association, inheritance and polymorphism.

 Hibernate Architecture

Hibernate:

1) itself opens connection to database,
2) converts HQL (Hibernate Query Language) statements to database specific statement,
3) receives result set,
4) then performs mapping of these database specific data to Java objects which are directly used by Java application.

Hibernate uses the database specification from Hibernate Properties file. Automatic mapping is performed on the basis of the properties defined in hbm XML file defined for particular Java object.


Read more..

Related Posts Plugin for WordPress, Blogger...
© javabynataraj.blogspot.com from 2009 - 2022. All rights reserved.