In this example, we will learn about Component Mapping in Hibernate Using Annotations. Component Mapping represents the has-a relationship, the composition is stronger association where the contained object has no existence of its own. For example, Employee has an Address, an address cannot exist separately without Employee. Since the Employee and Address entities are strongly related, it is better to store them in a single table. [Read more…]
In our previous example, we have seen how to create a Composite key in Hibernate using <composite-id> tag and Annotations. In this Embeddable Composite Primary Key example, we will be declaring the IDs (Primary Key fields) as a separate class annotated with @Embeddable annotation. An Employee is identified by its EmployeeId, which is defined by empId and department. Let’s dig into the code…
Whenever you need, to perform a specific task once after all the Spring Beans are created and the Application Context has been created then you can implement ApplicationRunner or CommandLineRunner interface. Both the interfaces works the same way and has a single run() method. A similar implementation is already there in Spring and many people would have known it JobLauncherCommandLineRunner which is used for running jobs in Spring Batch. [Read more…]
Previously we have learnt how to build a Spring Boot Hello World application using Maven and through Eclipse. In this Spring Boot example we will be building the same hello world application with a slight difference instead of building a executable JAR we will be be building a WAR file. We will be extending SpringBootServletInitializer in order to create deployable WAR file. [Read more…]
If a database table has more than one column as the primary key then we call it as composite primary key. In this Hibernate Composite Primary Key tutorial, we will learn how to define Composite Primary Key using <composite-id> tag and Annotations. [Read more…]
In the previous Spring Boot Hello World example we build our application with Maven through command prompt. In this article, we will be building the same Spring Boot Hello World example using IDE. I will be using Spring Tool Suite(STS) for development, you can also use Eclipse along with m2eclipse plugin. [Read more…]
Table per Class Hierarchy strategy will be having a single table for both the Parent class and the Sub class separated by a discriminator column. In Table per Subclass Hierarchy, subclass table will be mapped to the Parent class table by primary key and foreign key relationship. In Table Per Concrete Class Hierarchy also individual table will be created for each class. The disadvantage of this approach is that all the columns of the Primary class table will be again replicated in the Subclass table.
Previously we have seen how to implement Spring Security in a Hello World program using XML configuration. In this Spring Security Annotation Configuration Example, we will be using the same example but instead of XML configuration, we will be configuring it through annotation.
In the previous example we have seen Table per Class Hierarchy strategy, there we will be having a single table for both the Parent class and the Sub class separated by a discriminator column. In this Table per Subclass Hierarchy Example, subclass table will be mapped to the Parent class table by primary key and foreign key relationship.