Posty

Wyświetlam posty z etykietą Spring

Spring Data 2# - support for Couchbase

In this article we will have a look at how NoSQL Couchbase database is supported in Spring, especialy in Spring Data module. Couchbase is a document oriented NoSQL database which has gained a lot of popularity in the last few years. The main reason for that may be its specialization in a low latency data management for large scale web applications. Couchbase introduction Couchbase is a NoSQL document database which is a subset of a key-value stores. It is designed to store and retrieve data in JSON format. Each separate JSON item stored in the database is called a document. Couchbase does not force any specific schema on the data that is stored. It is often said that in NoSQL databases any schema specific constraints are moved from the database layer to the application layer . It often provides a better ways to develop a software with dynamic data structure changes since changes in the documents structure do not break any database constraints or schema. In this case you can up...

Hibernate 3# - Session API

Hibernate's Session is the interface that provides API for Java application to interact with persistence layer. It introduces CRUD methods to operate on entities. It also contains methods used to handle transactions. We can say, that Session  is the core interface in the Hibernate library. We will have a look at the core features of Session and how it is handled in Spring framework. Entity Management You will often see additional layers of abstraction over Session interface (like in Spring, which is discussed later). However, in this part of the article I will show some basic examples of using  Session object directly with regard to operations on entities. Entity is a domain model class. Its instance represents in the Java world a database row. As an entity example we will use following class: As you can see we are using multiple annotations which are needed by Hibernate to properly map the entity instance to a database row and vice versa. This annotations ...

Hibernate 2# - physical vs logical transactions

There are often some confusions in the regard of using 'transaction' term, especially when talking about ORM solutions like Hibernate. Sometimes transaction can have a different meaning depending on the context. It needs to be understood in order to be able to prevent any data anomalies during web development. We will have a look on what are the differences between physical and logical transactions.  Physical transaction Physical transaction is the actual transaction that takes place on the database level. It means that the beginning of the physical transaction is when actual transaction on the database level is started. The end of the physical transaction takes place when this transaction is commited or rollbacked on the database level. Atomicity of operations made during physical transaction is guarded by database itself. Logical transaction Logical transactions on the other hand are those handled on the the application side, for example Spring application. Logica...

Hibernate 1# - entity states overview

Obraz
Hibernate  is the most common choice when it comes to the ORM libraries used in Java backend projects. Being an ORM library Hibernate uses entities rather than SQL statements to manage database changes. In this article we will have a look at all the possible states of entities. This knowledge will give you awareness of what actions will Hibernate perform depending on the entity state. Our examples will be based on a simple Spring project. Manipulating entity states While using ORM libraries we trigger database changes by manipulating entities states. Entity class represents database table and entity instance represents row inside this table.  There are two different interfaces which can be used to handle entity state transitions: EntityManager Session Both enable us to manipulate Persistence Context . Persistence Context is responsible for handling entity states. The difference is that  EntityManager  is the JPA specification implementation while...