Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Copyright Red Hat Inc. and Hibernate Authors
*/
package org.hibernate;
import jakarta.persistence.EntityGraph;
import org.hibernate.graph.GraphSemantic;
import java.util.List;
/**
* A command-oriented API often used for performing bulk operations against
* the database. A stateless session has no persistence context, and always
* works directly with detached entity instances. When a method of this
* interface is called, any necessary interaction with the database happens
* immediately and synchronously.
*
* Viewed in opposition to {@link Session}, the {@code StatelessSession} is
* a whole competing programming model, one preferred by some developers
* for its simplicity and somewhat lower level of abstraction. But the two
* kinds of session are not enemies, and may comfortably coexist in a single
* program.
*
* A stateless session comes some with designed-in limitations:
*
*
it does not have a first-level cache,
*
nor interact with any second-level cache,
*
nor does it implement transactional write-behind or automatic dirty
* checking.
*
*
* Furthermore, the basic operations of a stateless session do not have
* corresponding {@linkplain jakarta.persistence.CascadeType cascade types},
* and so an operation performed via a stateless session never cascades to
* associated instances.
*
* The basic operations of a stateless session are {@link #get(Class, Object)},
* {@link #insert(Object)}, {@link #update(Object)}, {@link #delete(Object)},
* and {@link #upsert(Object)}. These operations are always performed
* synchronously, resulting in immediate access to the database. Notice that
* update is an explicit operation. There is no "flush" operation for a
* stateless session, and so modifications to entities are never automatically
* detected and made persistent.
*
* Similarly, lazy association fetching is an explicit operation. A collection
* or proxy may be fetched by calling {@link #fetch(Object)}.
*
* Stateless sessions are vulnerable to data aliasing effects, due to the
* lack of a first-level cache.
*
* On the other hand, for certain kinds of transactions, a stateless session
* may perform slightly faster than a stateful session.
*
* Certain rules applying to stateful sessions are relaxed in a stateless
* session:
*
*
it is not necessary to discard a session and its entities after an
* exception is thrown by a stateless sessions, and
*
when an exception is thrown by a stateless session, the current
* transaction is not automatically marked for rollback.
*
*
* Since version 7, the configuration property
* {@value org.hibernate.cfg.BatchSettings#STATEMENT_BATCH_SIZE} has no effect
* on a stateless session. Automatic batching may be enabled by explicitly
* {@linkplain #setJdbcBatchSize setting the batch size}. However, automatic
* batching has the side effect of delaying execution of the batched operation,
* thus undermining the synchronous nature of operations performed through a
* stateless session. A preferred approach is to explicitly batch operations via
* {@link #insertMultiple}, {@link #updateMultiple}, or {@link #deleteMultiple}.
*
* @author Gavin King
*/
public interface StatelessSession extends SharedSessionContract {
/**
* Close the stateless session and release the JDBC connection.
*/
void close();
/**
* Insert a record.
*
* If the entity {@code @Id} field is declared to be generated,
* for example, if it is annotated {@code @GeneratedValue}, the
* id is generated and assigned to the given instance.
*
* The {@link jakarta.persistence.PostPersist} callback will be
* triggered if the operation is successful.
*
* @param entity a new transient instance
*
* @return The identifier of the inserted entity
*/
Object insert(Object entity);
/**
* Insert multiple records.
*
* @param entities a list of transient instances to be inserted
*
* @since 7.0
*/
@Incubating
void insertMultiple(List