NetApp Advanced Java Interview Questions Answers

NetApp Most Frequently Asked Latest Advanced Java Interview Questions Answers

What Is Meant By Method Chaining?

Method chaining is a programming technique that is supported by many hibernate interfaces. This is less readable when compared to actual java code. And it is not mandatory to use this format. Look how a SessionFactory is created when we use method chaining.

SessionFactory sessions = new Configuration()
.addResource("myinstance/MyConfig.hbm.xml")
.setProperties( System.getProperties() )
.buildSessionFactory();

What Does Hibernate.properties File Consist Of?

This is a property file that should be placed in application class path. So when the Configuration object is created, hibernate is first initialized. At this moment the application will automatically detect and read this hibernate.properties file.
hibernate.connection.datasource = java:/comp/env/jdbc/AuctionDB
hibernate.transaction.factory_class =
net.sf.hibernate.transaction.JTATransactionFactory
hibernate.transaction.manager_lookup_class =
net.sf.hibernate.transaction.JBossTransactionManagerLookup
hibernate.dialect = net.sf.hibernate.dialect.PostgreSQLDialect

What Should Sessionfactory Be Placed So That It Can Be Easily Accessed?

As far as it is compared to J2EE environment, if the SessionFactory is placed in JNDI then it can be easily accessed and shared between different threads and various components that are hibernate aware. You can set the SessionFactory to a JNDI by configuring a property hibernate. session_ factory_ name in the hibernate. properties file.

What Are Pojos?

POJO stands for plain old java objects. These are just basic JavaBeans that have defined setter and getter methods for all the properties that are there in that bean. Besides they can also have some business logic related to that property. Hibernate applications works efficiently with POJOs rather then simple java classes.

What Is Object/relational Mapping Metadata?

ORM tools require a metadata format for the application to specify the mapping between classes and tables, properties and columns, associations and foreign keys, Java types and SQL types. This information is called the object/relational mapping metadata. It defines the transformation between the different data type systems and relationship representations.
NetApp Most Frequently Asked Latest Advanced Java Interview Questions Answers
NetApp Most Frequently Asked Latest Advanced Java Interview Questions Answers

What Is Hql?

HQL stands for Hibernate Query Language. Hibernate allows the user to express queries in its own portable SQL extension and this is called as HQL. It also allows the user to express in native SQL.

What Is Attribute Oriented Programming?

XDoclet has brought the concept of attribute-oriented programming to Java. Until JDK 1.5, the Java language had no support for annotations; now XDoclet uses the Javadoc tag format (@attribute) to specify class-, field-, or method-level metadata attributes. These attributes are used to generate hibernate mapping file automatically when the application is built. This kind of programming that works on attributes is called as Attribute Oriented Programming.

What Are The Different Methods Of Identifying An Object?

There are three methods by which an object can be identified.
i. Object identity –Objects are identical if they reside in the same memory location in the JVM. This can be checked by using the = = operator.
ii. Object equality – Objects are equal if they have the same value, as defined by the equals( ) method. Classes that don’t explicitly override this method inherit the implementation defined by java.lang.Object, which compares object identity.
iii. Database identity – Objects stored in a relational database are identical if they represent the same row or, equivalently, share the same table and primary key value.

What Are The Different Approaches To Represent An Inheritance Hierarchy?

i. Table per concrete class.
ii. Table per class hierarchy.
iii. Table per subclass.

What Are Managed Associations And Hibernate Associations?

Associations that are related to container management persistence are called managed associations. These are bi-directional associations. Coming to hibernate associations, these are unidirectional.

Why Do You Need Orm Tool Like Hibernate?

ORM tools like hibernate provide following benefits

Improved performance: Lazy loading, Sophisticated caching, Eager loading.
Improved productivity: High-level object-oriented API, Less Java code to write, No SQL to write.
Improved maintainability: A lot less code to write.
Improved portability: ORM framework generates database-specific SQL for you.

What Are The Main Advantages Of Orm Like Hibernate?

Hibernate implements extremely high-concurrency architecture with no resource-contention issues. This architecture scales extremely well as concurrency increases in a cluster or on a single machine.

Other performance related optimizations that hibernate performs are

Caching objects
Executing SQL statements later, when needed
Never updating unmodified objects
Efficient Collection Handling
Rolling two updates into one
Updating only the modified columns
Outer join fetching
Lazy collection initialization
Lazy object initialization.

What Are The Core Interfaces Of Hibernate Framework?

1. Session Interface: The basic interface for all hibernate applications. The instances are light weighted and can be created and destroyed without expensive process.
2. SessionFactory interface: The delivery of session objects to hibernate applications is done by this interface. For the whole application, there will be generally one SessionFactory and can be shared by all the application threads.
3. Configuration Interface: Hibernate bootstrap action is configured by this interface. The location specification is specified by specific mapping documents, is done by the instance of this interface.
4. Transaction Interface: This is an optional interface. This interface is used to abstract the code from a transaction that is implemented such as a JDBC / JTA transaction.
5. Query and Criteria interface: The queries from the user are allowed by this interface apart from controlling the flow of the query execution.

What Is A Hibernatetemplate?

HibernateTemplate is a helper class that is used to simplify the data access code. This class supports automatically converts HibernateExceptions which is a checked exception into DataAccessExceptions which is an unchecked exception. HibernateTemplate is typically used to implement data access or business logic services. The central method is execute(), that supports the Hibernate code that implements HibernateCallback interface.

What Are The Benefits Of Hibernatetemplate?

The benefits of HibernateTemplate are

HibernateTemplate, which is a Spring Template class, can simplify the interactions with Hibernate Sessions.
Various common functions are simplified into single method invocations.
The sessions of hibernate are closed automatically.
The exceptions will be caught automatically, and converts them into runtime exceptions.

What Is Hibernate Proxy?

Mapping of classes can be made into a proxy instead of a table. A proxy is returned when actually a load is called on a session. The proxy contains actual method to load the data. The proxy is created by default by Hibernate, for mapping a class to a file. The code to invoke Jdbc is contained in this class.

Explain The Types Of Hibernate Instance States.

The persistent class’s instance can be in any one of the three different states. These states are defined with a persistence context. The Hibernate has the following instance states

Transient: This instance is never been associated with any one of the persistence process. This does not have persistent identity like primary key value.
Persistent: A persistent context is made to associate with the current instance. It has persistent identity like primary key value and a corresponding row of a table in the data base. Hibernate guarantees the persistent identity is equivalent to the java Identity [object], for a particular persistence context.
Detatched: This instance association with a persistence context is only once and the context was closed or serialized to another process. The persistent identity is retained and it can be a corresponding row in a database.

Post a Comment

Previous Post Next Post