Object-Oriented Principles in Java

Java Interview Quesions

The object-oriented paradigm supports four major principles: abstraction, encapsulation, inheritance, and polymorphism. They are also known as four pillars of the object-oriented paradigm. Abstraction is the process of exposing the essential details of an entity, while ignoring the irrelevant details, to reduce the complexity for the users. Encapsulation is the process of bundling data and […]

Primitive Data Types in Java

Java Interview Quesions

In previous tutorial, we learned more about non-primitive datatypes. In this blog post, I will discuss primitive data types in detail. There are eight primitive data types supported by Java. Primitive data types are predefined by the language and named by a keyword. Let’s look at each primitive data types in below image. Integral Data […]

Field vs Property vs Mixed Access modes – JPA Tutorial

Java-persistence-API

In JPA, mapping information of an entity must be accessible to the ORM provider at runtime, so that when it is writing the data to storage, it can be obtained from the entity instance. Similarly, when the entity state is loaded from the storage, the provider runtime must be able to map the data into […]

Find Entity Example – JPA Tutorial

Java-persistence-API

In JPA, once an entity is persisted in the database, the next thing one typically wants to do is find it again. Let’s see how an entity can be found using the entity manager. Using EntityManager.find() In reality, there is really only one line that’s important: In above line, we are passing in the class […]

Save/Persist Entity Example – JPA Tutorial

Java-persistence-API

Persisting an entity is the operation of taking a transient entity, or one that does not yet have any persistent representation in the database, and storing its state so that it can be retrieved later. In this example, we have created an entity of type DepartmentEntity and persisted it to database. The line no. 13 […]

Remove/Delete Entity Example – JPA Tutorial

Java-persistence-API

In JPA, to remove an entity, the entity itself must be managed, meaning that it is present in the persistence context. This means that the calling application should have already loaded or accessed the entity and is now issuing a command to remove it. This is not normally a problem given that most often the […]

Configure JPA without persistence.xml

If you are working on Spring project and using JPA for data access, then you probably have persistence.xml file as well in META-INF folder. If you want to get rid of persistence.xml and configure datasource, persistence units name and entity paths in spring’s application-context.xml only then you can do it as below while configuring entityManagerFactoryBean. […]

Spring Hibernate JPA Configuration Example

application-folder-structure-hibernate-jpa

In this example, we will learn to configure Spring MVC and Hibernate with JPA along with few other things e.g. validation and custom property editors. I have been asked quite enough times to write this tutorial in past, so here it is. Feel free to post your doubts, comments and suggestions. If you want to […]

Use Eclipse Quick Search Plugin For Faster Text Searches

eclipse-quick-search-4

Yesterday, I came across very good eclipse plugin for doing text searches in eclipse workspace. Some of you may be already aware of this, but for those who don’t know it yet, go ahead and install this plugin and put some more speed into your development skills. The eclipse quick search plugin is part of […]

Java blog for smart concepts and coding practices