Posts

@Embeddable and @Embedded in Hibernate Annotation

Image
Before jumping to @Embeddable and @Embedded annotation. Let me explain about hibernate different objects:          Entity Object o    Entity object are those object which can stand alone like Student or Professor and has its own database identity.          Value Object o    Objects which cannot stand alone like Address as you need to map address with some Entities like Student. It will belongs to an entity, and its persistent state is embedded in the table row of the owning entity In short, always use @Embeddable for the value object and @Embedded with the entity class. Let's understand it by a simple example: We have one Address (Value object) and it is having attributes like city, state, zip code. Now we have two more different entity Student and Professor (Entity Object) . Student or Professor can have Address attributes just by embedding the Address into its Entity. The  @Embedd...

What is MappedSuperClass in hibernate ?

Image
MapperSuperClass ·         A mapped superclass has no separate table defined for it. ·         Designates a class whose mapping information is applied to the entities that inherit from it.  ·         A class designated with the  MappedSuperclass  annotation can be mapped in the same way as an entity except that the mappings will apply only to its subclasses since no table exists for the mapped superclass itself.  ·         When applied to the subclasses the inherited mappings will apply in the context of the subclass tables.  ·         Mapping information may be overridden in such subclasses by using the  AttributeOverride  and  AssociationOverride  annotations or corresponding XML elements. ·         It avoids the cod...

MongoDB basic Overview

Overview MongoDB is a cross-platform, documented oriented database and it is not based on schema like relational database. It uses dynamic schema and stores data in JSON format. It provides high performance, high availability, and easy scalability and it works on concept of collection and document. It is an open-source software. MongoDB is mainly written in C++, JavaScript and C. Download Please refer this link to setup MongoDB on your machine. Terminology ·          Document Document is similar to row/tuples in RDBMS, it is a set of key-value pairs and having dynamic schema i.e. the documents in the same collection do not need to have the same set of fields or structure and another document may hold different types of data. ·          Collection It is the equivalent to a TABLE in RDBMS and do not enforce a schema. It exists within a single database and each document wit...