heartin's blog

Your First Spring Program Using Java Configuration

We will create a simple class, configure it and test it. You can configure a Spring application through xml, or Java configuration or annotations along with xml or java configuration. In this example, we will see java configuration approach. We will have a Java class annotated with @Configuration to hold bean configuration.

 

Format for Answering Multiple Choice Questions

Please follow the below guidelines for answering questions.

  1. Answer within the question bank itself, without changing the name.

  2. Color your answers with blue color. 

  3. Color your execution results in yellow color. Sometimes you might be asked to first answer without trying out and then actually try compiling/executing it. This step is not mandatory.

Java Keywords and Identifier Naming Rules Quick Reference

This is a quick summary of important keywords and reserved words that you should not be using as an identifier. Identifier is a name given to any class, method, interface, enum or variable that we create. There is also added quick notes section with few important keywords that may be useful for exam or interview preparations.

 

Keywords in Java

  • class, interface, enum(added in 5.0), package, import, new, this,  super, return, void.

Class variables, Instance Variables and Local variables in Java

Based on the scope in which the variable is declared, we can classify variables as Class variables, Instance Variables and Local variables.

 

Class variables (or static variables)

Class variables (or static variables) are declared within a class and outside all methods using the static keyword.

Example: Static variable

class MyClass{

static int myVar;

Creating Composite Keys in Hibernate 4.3

A composite key is a primary key composed of multiple columns.

When you are creating a composite key, your persistent class must override the equals() and hashCode() method. This is required for for Hibernate caching to work correctly. It must also implement the Serializable interface.

Best way to do this is to create a class with all your composite key fields, mark it as @Embeddable and then annotate a field of that class type with @Id in your entity class.

@Embeddable

Entities and Value Types in Hibernate 4.3

An entity is a type on its own and has an existence of its own (e.g. Course, User etc.).

A value type is a type which doesn't have existence of its own, but belongs to an entity (e.g. Address of an User). Value types are always completely owned by their containing entity.

 

Defining entities and value types in Hibernate

Logging in Hibernate 4.3

You have different logging options in Hibernate and let us see some of those options quickly. Hibernate supports simple property based log enabling to supporting standard logging frameworks and even programmatically accessing log statistics.

 

Hibernate Framework References

We use various materials like books, internet resources etc. for our learning, for teaching and even for preparing notes. We will list those materials here for your reference. We might include only the very basic information required for our learning and training purposes here. You may refer to these additional materials for further reading and learning.

 

Books

  • Hibernate Recipes: A Problem-Solution Approach by by Joseph Ottinger, Gary Mak and Srinivas Guruzu.

Configuring a Hibernate 4.3 Application with JPA Entity Managers

In JPA, the EntityManager controls the lifecycle of the entities.

Different ORM vendors provide its own entity manager, which is usually a wrapper around the core API and thus supports the JPA programming interfaces, life cycles and query language.

You obtain the EntityManager from an entity manager factory. EntityManagerFactory has the same role as SessionFactory in Hibernate.

What is a framework?

A software framework is a reusable software platform that makes the life of developers easy by providing something commonly needed out of the box; developers can then use it or extend it.

For instance, Struts basically provides a MVC framework by providing a controller out of the box and an xml mechanism to configure MVC using xml files without hardcoding them in the code. 

Pages

Search the Web

Custom Search

Searches whole web. Use the search in the right sidebar to search only within javajee.com!!!