hibernate one to many, details explained

1. One to many 1). First create two entity classes studentinfo.java and studentxxb.java 1) The studentinfo.java table is as shown in the figure: package model; import java.util.Date; import java.util.HashSet; import java.util.Set; public class studentinfo { private Integer id; private String name; private String aihao; private date sjina; private Set<studentxxb> studentxxbs=new HashSet<>(); public studentinfo() { super(); […]

JavaHibernate 5.3.x

SchemeExport Hibernate automatically generates table structures based on entity classes and entity class mapping files. ?Sample code: <?xml version=’1.0′ encoding=’utf-8′?> <!DOCTYPE hibernate-configuration PUBLIC “-//Hibernate/Hibernate Configuration DTD//EN” “http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd”> <hibernate-configuration> <session-factory> <property name=”connection.url”>jdbc:mysql://172.16.65.200:3306/hibernate?useUnicode=true & amp;amp;characterEncoding=UTF8</property> <property name=”connection.driver_class”>com.mysql.jdbc.Driver</property> <property name=”connection.username”>root</property> <property name=”connection.password”>123456</property> <property name=”dialect”>org.hibernate.dialect.MySQL5Dialect</property> <property name=”hbm2ddl.auto”>create</property> <property name=”show_sql”>true</property> <property name=”format_sql”>true</property> <property name=”hibernate.current_session_context_class”>thread</property> <mapping class=”com.entity.Students” /> </session-factory> </hibernate-configuration> hibernate.cfg.xml […]

Create a new Hibernate project under IDEA

Hibernate Overview What is hibernate A persistence framework in the Java field AnORM framework for Java What is persistence Persistence refers to permanently saving objects to the database Persistence includes various operations related to the database (add, delete, modify, query) What is ORM ORM refers to Object/Relation Mapping ORM maps records in tables in relational […]

Could not initialize class org.hibernate.validator.internal.engine.ConfigurationImpl

HTTP Status 500 – Internal Server Error Type Exception Report Message Servlet.init() for servlet [dispatcherServlet] threw exception Description The server encountered an unexpected condition that prevented it from fulfilling the request. Exception javax.servlet.ServletException: Servlet.init() for servlet [dispatcherServlet] threw exception org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:800) org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:800) org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1471) org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) java.base/java.lang.Thread.run(Thread.java:834) Root Cause org.springframework.beans.factory.BeanCreationException: […]

Hibernate + Springboot implements the @Filter filter to automatically add conditional filtering. How to implement sprinboot multi-tenancy (shared table, by adding tenant_id)

Hibernate + Springboot implements @Filter filter to automatically add conditional filtering After three days and three nights of torture, I finally solved this requirement. First of all, this requirement is generally implemented through annotations. So the first step is to write an annotation by hand: @Target({<!– –>ElementType.PARAMETER, ElementType.METHOD})//The target location for annotation placement, METHOD can […]

Solon integrates hibernate, Solon uses hibernate

Solon integrates hibernate, Solon uses hibernate Solon integrates hibernate, Solon uses hibernate Environment jdk17 +, solo 2.5.4 (current latest: 09:42:12 on September 13, 2023), hibernate 6.3 (current latest version: 09:42:31 on September 13, 2023) Dependencies <dependency> <groupId>org.noear</groupId> <artifactId>solon-web</artifactId> <version>2.5.4</version> </dependency> <!– https://mvnrepository.com/artifact/cn.hutool/hutool-core –> <dependency> <groupId>cn.hutool</groupId> <artifactId>hutool-core</artifactId> <version>${hutool.version}</version> </dependency> <!– https://mvnrepository.com/artifact/org.hibernate.orm/hibernate-core –> <dependency> <groupId>org.hibernate.orm</groupId> <artifactId>hibernate-core</artifactId> <version>6.3.0.Final</version> […]

Hibernate: A simple understanding of cascade and retrieval

1.cascade: Implement cascade cud 1.1.What is cud In Hibernate, CUD refers to the abbreviation of create, update and delete operations on the database. Create: Through Hibernate, you can use persistent objects to insert data into the database. When saving a new persistent object to the database, Hibernate will automatically generate and execute the corresponding INSERT […]

Hibernate (Spring Data) fetching strategy

Article directory The sample code is put at the end, using the Springboot project 1 Introduction 2. Hibernate crawling strategy classification 2.1 Eager Loading 2.2 Lazy Loading 2.3 Subselect Loading 2.4 Batch Loading 3. Eager Loading 3.1 Overview 3.2 Entity class mapping configuration 3.3 Usage scenarios and precautions 4. Lazy Loading 4.1 Overview 4.2 Entity […]

Hibernate (Spring-Data) Guide to three types of entity inheritance to create tables

Article directory introduction 1. Overview of Hibernate entity inheritance 1.1 The concept and role of inheritance 1.2 Entity inheritance method in Hibernate 1.3 Basic annotations 2. Single table inheritance strategy 2.1 Overview 2.2 Table structure design 2.3 Entity class mapping configuration 3. Concrete class inheritance strategy 3.1 Overview 3.2 Table structure design 3.3 Entity class […]

Java framework Hibernate: making data persistence so easy

In the Java world, Hibernate is a very popular object-relational mapping (ORM) framework that provides developers with a simple yet powerful tool for mapping object models to relational databases. Hibernate not only simplifies the process of data persistence, but also improves development efficiency and code maintainability. This article will introduce you to the charm of […]