JAVA-20168 Migrating spring-jpa (#14257)
* JAVA-20168 Migrating spring-jpa * JAVA-20168 Migrate spring-jpa-2 * JAVA-20168 Remove unneeded annotation --------- Co-authored-by: timis1 <noreplay@yahoo.com>
This commit is contained in:
		
							parent
							
								
									c0171ff7ce
								
							
						
					
					
						commit
						86932cba3d
					
				| @ -66,7 +66,6 @@ | ||||
|         <module>spring-data-arangodb</module> | ||||
|         <module>spring-data-cassandra</module> | ||||
|         <module>spring-data-cassandra-test</module> | ||||
|         <!-- <module>spring-data-cassandra-reactive</module> FAILED --> | ||||
|         <module>spring-data-cosmosdb</module> | ||||
|         <module>spring-data-couchbase-2</module> | ||||
|         <module>spring-data-dynamodb</module> | ||||
| @ -99,8 +98,8 @@ | ||||
|         <module>spring-data-solr</module> | ||||
|         <!-- <module>spring-hibernate-3</module> FAILED --> | ||||
|         <!-- <module>spring-hibernate-5</module> FAILED --> <!-- long running --> | ||||
|         <!-- <module>spring-jpa</module> | ||||
|         <module>spring-jpa-2</module> FAILED --> | ||||
|         <module>spring-jpa</module> | ||||
|         <module>spring-jpa-2</module> | ||||
|         <module>spring-jdbc</module> | ||||
|         <module>spring-jooq</module> | ||||
|         <module>spring-mybatis</module> | ||||
|  | ||||
| @ -71,7 +71,7 @@ | ||||
|         <dependency> | ||||
|             <groupId>org.postgresql</groupId> | ||||
|             <artifactId>postgresql</artifactId> | ||||
|             <version>42.4.0</version> | ||||
|             <version>${postgresql.version}</version> | ||||
|             <scope>runtime</scope> | ||||
|         </dependency> | ||||
|         <dependency> | ||||
| @ -97,15 +97,26 @@ | ||||
|             <version>${org.springframework.version}</version> | ||||
|             <scope>test</scope> | ||||
|         </dependency> | ||||
|         <dependency> | ||||
|             <groupId>com.fasterxml.jackson.core</groupId> | ||||
|             <artifactId>jackson-databind</artifactId> | ||||
|             <version>${jakson-databind.version}</version> | ||||
|         </dependency> | ||||
|         <dependency> | ||||
|             <groupId>com.fasterxml.jackson.core</groupId> | ||||
|             <artifactId>jackson-core</artifactId> | ||||
|             <version>${jakson-core.version}</version> | ||||
|         </dependency> | ||||
|     </dependencies> | ||||
| 
 | ||||
|     <properties> | ||||
|         <!-- Spring --> | ||||
|         <org.springframework.version>5.2.0.RELEASE</org.springframework.version> | ||||
|         <spring-boot.version>2.2.6.RELEASE</spring-boot.version> | ||||
|         <org.springframework.version>6.0.9</org.springframework.version> | ||||
|         <spring-boot.version>3.1.0</spring-boot.version> | ||||
|         <!-- persistence --> | ||||
|         <tomcat-dbcp.version>9.0.0.M26</tomcat-dbcp.version> | ||||
|         <h2.version>2.1.214</h2.version> | ||||
|         <tomcat-dbcp.version>10.1.9</tomcat-dbcp.version> | ||||
|         <jakson-databind.version>2.15.1</jakson-databind.version> | ||||
|         <jakson-core.version>2.14.2</jakson-core.version> | ||||
|     </properties> | ||||
| 
 | ||||
| </project> | ||||
| @ -1,21 +1,9 @@ | ||||
| package com.baeldung.hibernate.bootstrap; | ||||
| 
 | ||||
| import com.google.common.base.Preconditions; | ||||
| import org.apache.tomcat.dbcp.dbcp2.BasicDataSource; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.context.annotation.Bean; | ||||
| import org.springframework.context.annotation.Configuration; | ||||
| import org.springframework.context.annotation.ImportResource; | ||||
| import org.springframework.context.annotation.PropertySource; | ||||
| import org.springframework.core.env.Environment; | ||||
| import org.springframework.orm.hibernate5.HibernateTransactionManager; | ||||
| import org.springframework.orm.hibernate5.LocalSessionFactoryBean; | ||||
| import org.springframework.transaction.PlatformTransactionManager; | ||||
| import org.springframework.transaction.annotation.EnableTransactionManagement; | ||||
| 
 | ||||
| import javax.sql.DataSource; | ||||
| import java.util.Properties; | ||||
| 
 | ||||
| @Configuration | ||||
| @EnableTransactionManagement | ||||
| @ImportResource({ "classpath:hibernate5Configuration.xml" }) | ||||
|  | ||||
| @ -1,7 +1,7 @@ | ||||
| package com.baeldung.hibernate.bootstrap.model; | ||||
| 
 | ||||
| import javax.persistence.Entity; | ||||
| import javax.persistence.Id; | ||||
| import jakarta.persistence.Entity; | ||||
| import jakarta.persistence.Id; | ||||
| 
 | ||||
| @Entity | ||||
| public class TestEntity { | ||||
|  | ||||
| @ -1,6 +1,6 @@ | ||||
| package com.baeldung.manytomany.model; | ||||
| 
 | ||||
| import javax.persistence.*; | ||||
| import jakarta.persistence.*; | ||||
| import java.util.HashSet; | ||||
| import java.util.Set; | ||||
| 
 | ||||
|  | ||||
| @ -1,6 +1,6 @@ | ||||
| package com.baeldung.manytomany.model; | ||||
| 
 | ||||
| import javax.persistence.*; | ||||
| import jakarta.persistence.*; | ||||
| 
 | ||||
| @Entity | ||||
| @Table(name = "course_rating") | ||||
|  | ||||
| @ -1,7 +1,7 @@ | ||||
| package com.baeldung.manytomany.model; | ||||
| 
 | ||||
| import javax.persistence.Column; | ||||
| import javax.persistence.Embeddable; | ||||
| import jakarta.persistence.Column; | ||||
| import jakarta.persistence.Embeddable; | ||||
| import java.io.Serializable; | ||||
| 
 | ||||
| @Embeddable | ||||
|  | ||||
| @ -1,6 +1,6 @@ | ||||
| package com.baeldung.manytomany.model; | ||||
| 
 | ||||
| import javax.persistence.*; | ||||
| import jakarta.persistence.*; | ||||
| import java.time.LocalDateTime; | ||||
| 
 | ||||
| @Entity | ||||
|  | ||||
| @ -1,6 +1,6 @@ | ||||
| package com.baeldung.manytomany.model; | ||||
| 
 | ||||
| import javax.persistence.*; | ||||
| import jakarta.persistence.*; | ||||
| import java.util.HashSet; | ||||
| import java.util.Set; | ||||
| 
 | ||||
|  | ||||
| @ -1,6 +1,6 @@ | ||||
| package com.baeldung.manytomanyremoval; | ||||
| 
 | ||||
| import javax.persistence.*; | ||||
| import jakarta.persistence.*; | ||||
| import java.util.HashSet; | ||||
| import java.util.Set; | ||||
| 
 | ||||
|  | ||||
| @ -1,7 +1,6 @@ | ||||
| package com.baeldung.manytomanyremoval; | ||||
| 
 | ||||
| 
 | ||||
| import javax.persistence.*; | ||||
| import jakarta.persistence.*; | ||||
| import java.util.HashSet; | ||||
| import java.util.Set; | ||||
| 
 | ||||
|  | ||||
| @ -1,6 +1,6 @@ | ||||
| package com.baeldung.manytomanyremoval; | ||||
| 
 | ||||
| import javax.persistence.*; | ||||
| import jakarta.persistence.*; | ||||
| 
 | ||||
| @Entity | ||||
| @Table(name = "category") | ||||
|  | ||||
| @ -1,7 +1,6 @@ | ||||
| package com.baeldung.manytomanyremoval; | ||||
| 
 | ||||
| 
 | ||||
| import javax.persistence.*; | ||||
| import jakarta.persistence.*; | ||||
| import java.util.HashSet; | ||||
| import java.util.Set; | ||||
| 
 | ||||
|  | ||||
| @ -4,8 +4,8 @@ import com.baeldung.multitenant.security.AuthenticationService; | ||||
| import org.springframework.core.annotation.Order; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import javax.servlet.*; | ||||
| import javax.servlet.http.HttpServletRequest; | ||||
| import jakarta.servlet.*; | ||||
| import jakarta.servlet.http.HttpServletRequest; | ||||
| import java.io.IOException; | ||||
| 
 | ||||
| @Component | ||||
|  | ||||
| @ -1,11 +1,11 @@ | ||||
| package com.baeldung.multitenant.domain; | ||||
| 
 | ||||
| import javax.persistence.Column; | ||||
| import javax.persistence.Entity; | ||||
| import javax.persistence.Id; | ||||
| import javax.persistence.Table; | ||||
| import javax.persistence.GeneratedValue; | ||||
| import javax.persistence.GenerationType; | ||||
| import jakarta.persistence.Column; | ||||
| import jakarta.persistence.Entity; | ||||
| import jakarta.persistence.Id; | ||||
| import jakarta.persistence.Table; | ||||
| import jakarta.persistence.GeneratedValue; | ||||
| import jakarta.persistence.GenerationType; | ||||
| 
 | ||||
| @Entity | ||||
| @Table(name = "employee") | ||||
|  | ||||
| @ -4,11 +4,11 @@ import org.springframework.security.core.Authentication; | ||||
| import org.springframework.security.core.context.SecurityContextHolder; | ||||
| import org.springframework.web.filter.GenericFilterBean; | ||||
| 
 | ||||
| import javax.servlet.FilterChain; | ||||
| import javax.servlet.ServletException; | ||||
| import javax.servlet.ServletRequest; | ||||
| import javax.servlet.ServletResponse; | ||||
| import javax.servlet.http.HttpServletRequest; | ||||
| import jakarta.servlet.FilterChain; | ||||
| import jakarta.servlet.ServletException; | ||||
| import jakarta.servlet.ServletRequest; | ||||
| import jakarta.servlet.ServletResponse; | ||||
| import jakarta.servlet.http.HttpServletRequest; | ||||
| import java.io.IOException; | ||||
| 
 | ||||
| public class AuthenticationFilter extends GenericFilterBean { | ||||
|  | ||||
| @ -5,8 +5,8 @@ import io.jsonwebtoken.SignatureAlgorithm; | ||||
| import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; | ||||
| import org.springframework.security.core.Authentication; | ||||
| 
 | ||||
| import javax.servlet.http.HttpServletRequest; | ||||
| import javax.servlet.http.HttpServletResponse; | ||||
| import jakarta.servlet.http.HttpServletRequest; | ||||
| import jakarta.servlet.http.HttpServletResponse; | ||||
| import java.util.Collections; | ||||
| import java.util.Date; | ||||
| 
 | ||||
|  | ||||
| @ -9,10 +9,10 @@ import org.springframework.security.core.GrantedAuthority; | ||||
| import org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter; | ||||
| import org.springframework.security.web.util.matcher.AntPathRequestMatcher; | ||||
| 
 | ||||
| import javax.servlet.FilterChain; | ||||
| import javax.servlet.ServletException; | ||||
| import javax.servlet.http.HttpServletRequest; | ||||
| import javax.servlet.http.HttpServletResponse; | ||||
| import jakarta.servlet.FilterChain; | ||||
| import jakarta.servlet.ServletException; | ||||
| import jakarta.servlet.http.HttpServletRequest; | ||||
| import jakarta.servlet.http.HttpServletResponse; | ||||
| import java.io.IOException; | ||||
| import java.util.Collection; | ||||
| import java.util.Collections; | ||||
|  | ||||
| @ -2,32 +2,39 @@ package com.baeldung.multitenant.security; | ||||
| 
 | ||||
| import org.springframework.context.annotation.Bean; | ||||
| import org.springframework.context.annotation.Configuration; | ||||
| import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; | ||||
| import org.springframework.security.authentication.AuthenticationManager; | ||||
| import org.springframework.security.config.Customizer; | ||||
| import org.springframework.security.config.annotation.web.builders.HttpSecurity; | ||||
| import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; | ||||
| import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; | ||||
| import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; | ||||
| import org.springframework.security.config.annotation.web.configurers.HeadersConfigurer; | ||||
| import org.springframework.security.config.http.SessionCreationPolicy; | ||||
| import org.springframework.security.core.userdetails.User; | ||||
| import org.springframework.security.core.userdetails.UserDetails; | ||||
| import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; | ||||
| import org.springframework.security.crypto.password.PasswordEncoder; | ||||
| import org.springframework.security.provisioning.InMemoryUserDetailsManager; | ||||
| import org.springframework.security.web.SecurityFilterChain; | ||||
| import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; | ||||
| 
 | ||||
| @Configuration | ||||
| @EnableWebSecurity | ||||
| public class SecurityConfiguration extends WebSecurityConfigurerAdapter { | ||||
| public class SecurityConfiguration { | ||||
| 
 | ||||
|     @Override | ||||
|     protected void configure(AuthenticationManagerBuilder auth) throws Exception { | ||||
|         auth.inMemoryAuthentication() | ||||
|           .passwordEncoder(passwordEncoder()) | ||||
|           .withUser("user") | ||||
|           .password(passwordEncoder().encode("baeldung")) | ||||
|           .roles("tenant_1"); | ||||
|     @Bean | ||||
|     public InMemoryUserDetailsManager userDetailsService() { | ||||
|         UserDetails user1 = User | ||||
|                 .withUsername("user") | ||||
|                 .password(passwordEncoder().encode("baeldung")) | ||||
|                 .roles("tenant_1") | ||||
|                 .build(); | ||||
| 
 | ||||
|         auth.inMemoryAuthentication() | ||||
|           .passwordEncoder(passwordEncoder()) | ||||
|           .withUser("admin") | ||||
|           .password(passwordEncoder().encode("baeldung")) | ||||
|           .roles("tenant_2"); | ||||
|         UserDetails user2 = User | ||||
|                 .withUsername("admin") | ||||
|                 .password(passwordEncoder().encode("baeldung")) | ||||
|                 .roles("tenant_2") | ||||
|                 .build(); | ||||
|         return new InMemoryUserDetailsManager(user1, user2); | ||||
|     } | ||||
| 
 | ||||
|     @Bean | ||||
| @ -35,22 +42,19 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter { | ||||
|         return new BCryptPasswordEncoder(); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     protected void configure(HttpSecurity http) throws Exception { | ||||
|     @Bean | ||||
|     public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { | ||||
|         final AuthenticationManager authenticationManager = http.getSharedObject(AuthenticationManager.class); | ||||
|         http | ||||
|           .authorizeRequests() | ||||
|           .antMatchers("/login").permitAll() | ||||
|           .anyRequest().authenticated() | ||||
|           .and() | ||||
|           .sessionManagement() | ||||
|           .sessionCreationPolicy(SessionCreationPolicy.STATELESS) | ||||
|           .and() | ||||
|           .addFilterBefore(new LoginFilter("/login", authenticationManager()), | ||||
|             UsernamePasswordAuthenticationFilter.class) | ||||
|           .addFilterBefore(new AuthenticationFilter(), UsernamePasswordAuthenticationFilter.class) | ||||
|           .csrf().disable() | ||||
|           .headers().frameOptions().disable() | ||||
|           .and() | ||||
|           .httpBasic(); | ||||
|                 .authorizeHttpRequests(authorize -> | ||||
|                         authorize.requestMatchers("/login").permitAll().anyRequest().authenticated()) | ||||
|                 .sessionManagement(securityContext -> securityContext.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) | ||||
|                 .addFilterBefore(new LoginFilter("/login", authenticationManager), UsernamePasswordAuthenticationFilter.class) | ||||
|                 .addFilterBefore(new AuthenticationFilter(), UsernamePasswordAuthenticationFilter.class) | ||||
|                 .csrf(AbstractHttpConfigurer::disable) | ||||
|                 .headers(header -> header.frameOptions(HeadersConfigurer.FrameOptionsConfig::disable)) | ||||
|                 .httpBasic(Customizer.withDefaults()); | ||||
| 
 | ||||
|         return http.build(); | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -1,7 +1,7 @@ | ||||
| package com.baeldung.spring.dao.generics; | ||||
| 
 | ||||
| import javax.persistence.EntityManager; | ||||
| import javax.persistence.PersistenceContext; | ||||
| import jakarta.persistence.EntityManager; | ||||
| import jakarta.persistence.PersistenceContext; | ||||
| import java.io.Serializable; | ||||
| import java.util.List; | ||||
| 
 | ||||
|  | ||||
| @ -2,7 +2,7 @@ package com.baeldung.spring.dao.generics; | ||||
| 
 | ||||
| import org.hibernate.annotations.CacheConcurrencyStrategy; | ||||
| 
 | ||||
| import javax.persistence.*; | ||||
| import jakarta.persistence.*; | ||||
| import java.io.Serializable; | ||||
| 
 | ||||
| @Entity | ||||
|  | ||||
| @ -1,6 +1,6 @@ | ||||
| package com.baeldung.spring.hibernate; | ||||
| 
 | ||||
| import javax.persistence.*; | ||||
| import jakarta.persistence.*; | ||||
| import java.io.Serializable; | ||||
| 
 | ||||
| @Entity | ||||
|  | ||||
| @ -2,10 +2,10 @@ package com.baeldung.spring.transaction; | ||||
| 
 | ||||
| import java.io.Serializable; | ||||
| 
 | ||||
| import javax.persistence.Column; | ||||
| import javax.persistence.Entity; | ||||
| import javax.persistence.Id; | ||||
| import javax.persistence.Table; | ||||
| import jakarta.persistence.Column; | ||||
| import jakarta.persistence.Entity; | ||||
| import jakarta.persistence.Id; | ||||
| import jakarta.persistence.Table; | ||||
| 
 | ||||
| @Entity | ||||
| @Table(name = "course") | ||||
|  | ||||
| @ -5,7 +5,7 @@ jdbc.user=tutorialuser | ||||
| jdbc.pass=tutorialmy5ql | ||||
| 
 | ||||
| # hibernate.X | ||||
| hibernate.dialect=org.hibernate.dialect.MySQL5Dialect | ||||
| hibernate.dialect=org.hibernate.dialect.MySQLDialect | ||||
| hibernate.show_sql=false | ||||
| hibernate.hbm2ddl.auto=create-drop | ||||
| 
 | ||||
|  | ||||
| @ -4,14 +4,12 @@ import com.baeldung.hibernate.bootstrap.model.TestEntity; | ||||
| import org.hibernate.Session; | ||||
| import org.hibernate.SessionFactory; | ||||
| import org.junit.Assert; | ||||
| import org.junit.Before; | ||||
| import org.junit.Test; | ||||
| import org.junit.runner.RunWith; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.test.annotation.Commit; | ||||
| import org.springframework.test.context.ContextConfiguration; | ||||
| import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; | ||||
| import org.springframework.test.context.support.AnnotationConfigContextLoader; | ||||
| import org.springframework.test.context.transaction.TestTransaction; | ||||
| import org.springframework.transaction.annotation.Transactional; | ||||
| 
 | ||||
| @ -33,7 +31,7 @@ public class HibernateBootstrapIntegrationTest { | ||||
| 
 | ||||
|         TestEntity newEntity = new TestEntity(); | ||||
|         newEntity.setId(1); | ||||
|         session.save(newEntity); | ||||
|         session.persist(newEntity); | ||||
| 
 | ||||
|         TestEntity searchEntity = session.find(TestEntity.class, 1); | ||||
| 
 | ||||
| @ -49,7 +47,7 @@ public class HibernateBootstrapIntegrationTest { | ||||
| 
 | ||||
|         TestEntity newEntity = new TestEntity(); | ||||
|         newEntity.setId(1); | ||||
|         session.save(newEntity); | ||||
|         session.persist(newEntity); | ||||
| 
 | ||||
|         TestEntity searchEntity = session.find(TestEntity.class, 1); | ||||
| 
 | ||||
| @ -74,7 +72,7 @@ public class HibernateBootstrapIntegrationTest { | ||||
| 
 | ||||
|         Assert.assertNotNull(searchEntity); | ||||
| 
 | ||||
|         session.delete(searchEntity); | ||||
|         session.remove(searchEntity); | ||||
|         session.flush(); | ||||
| 
 | ||||
|         TestTransaction.end(); | ||||
| @ -90,7 +88,7 @@ public class HibernateBootstrapIntegrationTest { | ||||
| 
 | ||||
|         Assert.assertNotNull(searchEntity); | ||||
| 
 | ||||
|         session.delete(searchEntity); | ||||
|         session.remove(searchEntity); | ||||
|         session.flush(); | ||||
| 
 | ||||
|         assertTrue(TestTransaction.isActive()); | ||||
| @ -121,7 +119,7 @@ public class HibernateBootstrapIntegrationTest { | ||||
| 
 | ||||
|         TestEntity newEntity = new TestEntity(); | ||||
|         newEntity.setId(1); | ||||
|         session.save(newEntity); | ||||
|         session.persist(newEntity); | ||||
| 
 | ||||
|         TestEntity searchEntity = session.find(TestEntity.class, 1); | ||||
| 
 | ||||
| @ -145,7 +143,7 @@ public class HibernateBootstrapIntegrationTest { | ||||
| 
 | ||||
|         Assert.assertNotNull(searchEntity); | ||||
| 
 | ||||
|         session.delete(searchEntity); | ||||
|         session.remove(searchEntity); | ||||
|         session.flush(); | ||||
| 
 | ||||
|         TestTransaction.flagForRollback(); | ||||
| @ -162,7 +160,7 @@ public class HibernateBootstrapIntegrationTest { | ||||
| 
 | ||||
|         Assert.assertNotNull(searchEntity); | ||||
| 
 | ||||
|         session.delete(searchEntity); | ||||
|         session.remove(searchEntity); | ||||
|         session.flush(); | ||||
| 
 | ||||
|         assertTrue(TestTransaction.isActive()); | ||||
|  | ||||
| @ -26,7 +26,7 @@ public class HibernateXMLBootstrapIntegrationTest { | ||||
| 
 | ||||
|         TestEntity newEntity = new TestEntity(); | ||||
|         newEntity.setId(1); | ||||
|         session.save(newEntity); | ||||
|         session.persist(newEntity); | ||||
| 
 | ||||
|         TestEntity searchEntity = session.find(TestEntity.class, 1); | ||||
| 
 | ||||
|  | ||||
| @ -11,8 +11,8 @@ import org.springframework.test.context.ContextConfiguration; | ||||
| import org.springframework.test.context.junit4.SpringRunner; | ||||
| import org.springframework.transaction.annotation.Transactional; | ||||
| 
 | ||||
| import javax.persistence.EntityManager; | ||||
| import javax.persistence.PersistenceContext; | ||||
| import jakarta.persistence.EntityManager; | ||||
| import jakarta.persistence.PersistenceContext; | ||||
| 
 | ||||
| import static org.hamcrest.CoreMatchers.is; | ||||
| import static org.hamcrest.CoreMatchers.notNullValue; | ||||
|  | ||||
| @ -11,7 +11,7 @@ import org.springframework.orm.jpa.JpaVendorAdapter; | ||||
| import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; | ||||
| import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; | ||||
| 
 | ||||
| import javax.persistence.EntityManagerFactory; | ||||
| import jakarta.persistence.EntityManagerFactory; | ||||
| import javax.sql.DataSource; | ||||
| import java.util.HashMap; | ||||
| import java.util.Map; | ||||
|  | ||||
| @ -10,7 +10,7 @@ import org.springframework.test.context.ContextConfiguration; | ||||
| import org.springframework.test.context.junit.jupiter.SpringExtension; | ||||
| import org.springframework.transaction.annotation.Transactional; | ||||
| 
 | ||||
| import javax.persistence.EntityManager; | ||||
| import jakarta.persistence.EntityManager; | ||||
| 
 | ||||
| @ExtendWith(SpringExtension.class) | ||||
| @ContextConfiguration(classes = TestContextConfig.class) | ||||
|  | ||||
| @ -10,7 +10,7 @@ import org.springframework.test.context.ContextConfiguration; | ||||
| import org.springframework.test.context.junit.jupiter.SpringExtension; | ||||
| import org.springframework.transaction.annotation.Transactional; | ||||
| 
 | ||||
| import javax.persistence.EntityManager; | ||||
| import jakarta.persistence.EntityManager; | ||||
| 
 | ||||
| @ExtendWith(SpringExtension.class) | ||||
| @ContextConfiguration(classes = TestContextConfig.class) | ||||
|  | ||||
| @ -76,21 +76,21 @@ | ||||
|             <version>${hibernate-validator.version}</version> | ||||
|         </dependency> | ||||
|         <dependency> | ||||
|             <groupId>javax.el</groupId> | ||||
|             <artifactId>javax.el-api</artifactId> | ||||
|             <version>${javax.el-api.version}</version> | ||||
|             <groupId>org.glassfish.expressly</groupId> | ||||
|             <artifactId>expressly</artifactId> | ||||
|             <version>${expressly-language.version}</version> | ||||
|         </dependency> | ||||
|         <!-- web --> | ||||
|         <dependency> | ||||
|             <groupId>javax.servlet</groupId> | ||||
|             <artifactId>jstl</artifactId> | ||||
|             <version>${jstl.version}</version> | ||||
|             <groupId>jakarta.servlet.jsp.jstl</groupId> | ||||
|             <artifactId>jakarta.servlet.jsp.jstl-api</artifactId> | ||||
|             <version>${jakarta-servlet-jpa-jstl-api.version}</version> | ||||
|         </dependency> | ||||
|         <dependency> | ||||
|             <groupId>javax.servlet</groupId> | ||||
|             <artifactId>servlet-api</artifactId> | ||||
|             <groupId>jakarta.servlet</groupId> | ||||
|             <artifactId>jakarta.servlet-api</artifactId> | ||||
|             <version>${jakarta.servlet-api.version}</version> | ||||
|             <scope>provided</scope> | ||||
|             <version>${javax.servlet.servlet-api.version}</version> | ||||
|         </dependency> | ||||
|         <!-- utils --> | ||||
|         <dependency> | ||||
| @ -115,17 +115,18 @@ | ||||
| 
 | ||||
|     <properties> | ||||
|         <!-- Spring --> | ||||
|         <org.springframework.version>5.1.5.RELEASE</org.springframework.version> | ||||
|         <javassist.version>3.21.0-GA</javassist.version> | ||||
|         <mysql-connector-java.version>6.0.6</mysql-connector-java.version> | ||||
|         <spring-data-jpa.version>2.1.5.RELEASE</spring-data-jpa.version> | ||||
|         <org.springframework.version>6.0.6</org.springframework.version> | ||||
|         <javassist.version>3.29.2-GA</javassist.version> | ||||
|         <mysql-connector-java.version>8.0.33</mysql-connector-java.version> | ||||
|         <spring-data-jpa.version>3.1.0</spring-data-jpa.version> | ||||
|         <!-- web --> | ||||
|         <javax.servlet.servlet-api.version>2.5</javax.servlet.servlet-api.version> | ||||
|         <jakarta.servlet-api.version>6.0.0</jakarta.servlet-api.version> | ||||
|         <!-- various --> | ||||
|         <hibernate-validator.version>6.0.15.Final</hibernate-validator.version> | ||||
|         <xml-apis.version>1.4.01</xml-apis.version> | ||||
|         <javax.el-api.version>2.2.5</javax.el-api.version> | ||||
|         <hibernate-validator.version>8.0.0.Final</hibernate-validator.version> | ||||
|         <xml-apis.version>2.0.2</xml-apis.version> | ||||
|         <h2.version>2.1.214</h2.version> | ||||
|         <expressly-language.version>5.0.0</expressly-language.version> | ||||
|         <jakarta-servlet-jpa-jstl-api.version>3.0.0</jakarta-servlet-jpa-jstl-api.version> | ||||
|     </properties> | ||||
| 
 | ||||
| </project> | ||||
| @ -2,11 +2,11 @@ package com.baeldung.annotations; | ||||
| 
 | ||||
| import java.util.Date; | ||||
| 
 | ||||
| import javax.persistence.Entity; | ||||
| import javax.persistence.NamedStoredProcedureQueries; | ||||
| import javax.persistence.NamedStoredProcedureQuery; | ||||
| import javax.persistence.ParameterMode; | ||||
| import javax.persistence.StoredProcedureParameter; | ||||
| import jakarta.persistence.Entity; | ||||
| import jakarta.persistence.NamedStoredProcedureQueries; | ||||
| import jakarta.persistence.NamedStoredProcedureQuery; | ||||
| import jakarta.persistence.ParameterMode; | ||||
| import jakarta.persistence.StoredProcedureParameter; | ||||
| 
 | ||||
| import com.baeldung.persistence.multiple.model.user.User; | ||||
| import org.springframework.data.annotation.CreatedBy; | ||||
| @ -16,13 +16,13 @@ import org.springframework.data.annotation.LastModifiedBy; | ||||
| import org.springframework.data.annotation.Transient; | ||||
| 
 | ||||
| @Entity | ||||
| @NamedStoredProcedureQueries({  | ||||
| @NamedStoredProcedureQueries({ | ||||
|     @NamedStoredProcedureQuery( | ||||
|         name = "count_by_name",  | ||||
|         procedureName = "person.count_by_name",  | ||||
|         parameters = {  | ||||
|                 @StoredProcedureParameter( | ||||
|                     mode = ParameterMode.IN,  | ||||
|                     mode = ParameterMode.IN, | ||||
|                     name = "name",  | ||||
|                     type = String.class), | ||||
|                 @StoredProcedureParameter( | ||||
|  | ||||
| @ -1,6 +1,6 @@ | ||||
| package com.baeldung.annotations; | ||||
| 
 | ||||
| import javax.persistence.LockModeType; | ||||
| import jakarta.persistence.LockModeType; | ||||
| 
 | ||||
| import org.springframework.data.jpa.repository.Lock; | ||||
| import org.springframework.data.jpa.repository.Modifying; | ||||
|  | ||||
| @ -2,7 +2,7 @@ package com.baeldung.config; | ||||
| 
 | ||||
| import java.util.Properties; | ||||
| 
 | ||||
| import javax.persistence.EntityManagerFactory; | ||||
| import jakarta.persistence.EntityManagerFactory; | ||||
| import javax.sql.DataSource; | ||||
| 
 | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
|  | ||||
| @ -4,14 +4,13 @@ import org.springframework.context.annotation.Bean; | ||||
| import org.springframework.context.annotation.ComponentScan; | ||||
| import org.springframework.context.annotation.Configuration; | ||||
| import org.springframework.web.servlet.config.annotation.EnableWebMvc; | ||||
| import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; | ||||
| import org.springframework.web.servlet.view.InternalResourceViewResolver; | ||||
| import org.springframework.web.servlet.view.JstlView; | ||||
| 
 | ||||
| @EnableWebMvc | ||||
| @Configuration | ||||
| @ComponentScan({ "com.baeldung.web" }) | ||||
| public class SpringWebConfig extends WebMvcConfigurerAdapter { | ||||
| public class SpringWebConfig { | ||||
| 
 | ||||
|     @Bean | ||||
|     public InternalResourceViewResolver viewResolver() { | ||||
|  | ||||
| @ -2,7 +2,7 @@ package com.baeldung.config; | ||||
| 
 | ||||
| import java.util.Properties; | ||||
| 
 | ||||
| import javax.persistence.EntityManagerFactory; | ||||
| import jakarta.persistence.EntityManagerFactory; | ||||
| import javax.sql.DataSource; | ||||
| 
 | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
|  | ||||
| @ -1,6 +1,6 @@ | ||||
| package com.baeldung.inmemory.persistence.model; | ||||
| 
 | ||||
| import javax.persistence.Embeddable; | ||||
| import jakarta.persistence.Embeddable; | ||||
| 
 | ||||
| @Embeddable | ||||
| public class KVTag { | ||||
|  | ||||
| @ -1,6 +1,6 @@ | ||||
| package com.baeldung.inmemory.persistence.model; | ||||
| 
 | ||||
| import javax.persistence.Embeddable; | ||||
| import jakarta.persistence.Embeddable; | ||||
| 
 | ||||
| @Embeddable | ||||
| public class LocationTag { | ||||
|  | ||||
| @ -1,6 +1,6 @@ | ||||
| package com.baeldung.inmemory.persistence.model; | ||||
| 
 | ||||
| import javax.persistence.*; | ||||
| import jakarta.persistence.*; | ||||
| import java.util.HashSet; | ||||
| import java.util.Set; | ||||
| 
 | ||||
|  | ||||
| @ -1,6 +1,6 @@ | ||||
| package com.baeldung.inmemory.persistence.model; | ||||
| 
 | ||||
| import javax.persistence.*; | ||||
| import jakarta.persistence.*; | ||||
| import java.util.HashSet; | ||||
| import java.util.Set; | ||||
| 
 | ||||
|  | ||||
| @ -1,6 +1,6 @@ | ||||
| package com.baeldung.inmemory.persistence.model; | ||||
| 
 | ||||
| import javax.persistence.Embeddable; | ||||
| import jakarta.persistence.Embeddable; | ||||
| 
 | ||||
| @Embeddable | ||||
| public class SkillTag { | ||||
|  | ||||
| @ -2,9 +2,9 @@ package com.baeldung.inmemory.persistence.model; | ||||
| 
 | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
| import javax.persistence.ElementCollection; | ||||
| import javax.persistence.Entity; | ||||
| import javax.persistence.Id; | ||||
| import jakarta.persistence.ElementCollection; | ||||
| import jakarta.persistence.Entity; | ||||
| import jakarta.persistence.Id; | ||||
| 
 | ||||
| @Entity | ||||
| public class Student { | ||||
|  | ||||
| @ -3,8 +3,8 @@ package com.baeldung.persistence.dao; | ||||
| import java.io.Serializable; | ||||
| import java.util.List; | ||||
| 
 | ||||
| import javax.persistence.EntityManager; | ||||
| import javax.persistence.PersistenceContext; | ||||
| import jakarta.persistence.EntityManager; | ||||
| import jakarta.persistence.PersistenceContext; | ||||
| 
 | ||||
| public abstract class AbstractJpaDAO<T extends Serializable> { | ||||
| 
 | ||||
|  | ||||
| @ -3,15 +3,15 @@ package com.baeldung.persistence.model; | ||||
| import java.io.Serializable; | ||||
| import java.util.List; | ||||
| 
 | ||||
| import javax.persistence.CascadeType; | ||||
| import javax.persistence.Column; | ||||
| import javax.persistence.Entity; | ||||
| import javax.persistence.FetchType; | ||||
| import javax.persistence.GeneratedValue; | ||||
| import javax.persistence.GenerationType; | ||||
| import javax.persistence.Id; | ||||
| import javax.persistence.OneToMany; | ||||
| import javax.persistence.OrderBy; | ||||
| import jakarta.persistence.CascadeType; | ||||
| import jakarta.persistence.Column; | ||||
| import jakarta.persistence.Entity; | ||||
| import jakarta.persistence.FetchType; | ||||
| import jakarta.persistence.GeneratedValue; | ||||
| import jakarta.persistence.GenerationType; | ||||
| import jakarta.persistence.Id; | ||||
| import jakarta.persistence.OneToMany; | ||||
| import jakarta.persistence.OrderBy; | ||||
| 
 | ||||
| @Entity | ||||
| public class Bar implements Serializable { | ||||
|  | ||||
| @ -2,7 +2,7 @@ package com.baeldung.persistence.model; | ||||
| 
 | ||||
| import org.hibernate.annotations.CacheConcurrencyStrategy; | ||||
| 
 | ||||
| import javax.persistence.*; | ||||
| import jakarta.persistence.*; | ||||
| import java.io.Serializable; | ||||
| 
 | ||||
| @Entity | ||||
|  | ||||
| @ -1,6 +1,6 @@ | ||||
| package com.baeldung.persistence.multiple.model.user; | ||||
| 
 | ||||
| import javax.persistence.*; | ||||
| import jakarta.persistence.*; | ||||
| 
 | ||||
| @Entity | ||||
| @Table(schema = "spring_jpa_user") | ||||
|  | ||||
| @ -1,6 +1,6 @@ | ||||
| package com.baeldung.persistence.multiple.model.user; | ||||
| 
 | ||||
| import javax.persistence.*; | ||||
| import jakarta.persistence.*; | ||||
| import java.util.List; | ||||
| 
 | ||||
| @Entity | ||||
|  | ||||
| @ -1,11 +1,11 @@ | ||||
| package com.baeldung.sqlfiles; | ||||
| 
 | ||||
| import static javax.persistence.GenerationType.IDENTITY; | ||||
| import static jakarta.persistence.GenerationType.IDENTITY; | ||||
| 
 | ||||
| import javax.persistence.Column; | ||||
| import javax.persistence.Entity; | ||||
| import javax.persistence.GeneratedValue; | ||||
| import javax.persistence.Id; | ||||
| import jakarta.persistence.Column; | ||||
| import jakarta.persistence.Entity; | ||||
| import jakarta.persistence.GeneratedValue; | ||||
| import jakarta.persistence.Id; | ||||
| 
 | ||||
| @Entity | ||||
| public class Country { | ||||
|  | ||||
| @ -5,7 +5,7 @@ jdbc.user=tutorialuser | ||||
| jdbc.pass=tutorialmy5ql | ||||
| 
 | ||||
| # hibernate.X | ||||
| hibernate.dialect=org.hibernate.dialect.MySQL5Dialect | ||||
| hibernate.dialect=org.hibernate.dialect.MySQLDialect | ||||
| hibernate.show_sql=false | ||||
| hibernate.hbm2ddl.auto=create-drop | ||||
| hibernate.cache.use_second_level_cache=false | ||||
|  | ||||
| @ -3,7 +3,7 @@ jdbc.url=jdbc:mysql://localhost:3306/myDb | ||||
| jdbc.user=tutorialuser | ||||
| jdbc.pass=tutorialpass | ||||
| 
 | ||||
| hibernate.dialect=org.hibernate.dialect.MySQL5Dialect | ||||
| hibernate.dialect=org.hibernate.dialect.MySQLDialect | ||||
| hibernate.show_sql=false | ||||
| hibernate.hbm2ddl.auto=create-drop | ||||
| 
 | ||||
|  | ||||
| @ -6,11 +6,11 @@ | ||||
|         <class>com.baeldung.persistence.model.Foo</class> | ||||
|         <class>com.baeldung.persistence.model.Bar</class> | ||||
|         <properties> | ||||
|             <property name="javax.persistence.jdbc.user" value="root"/> | ||||
|             <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/> | ||||
|             <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/HIBERTEST"/> | ||||
|             <property name="javax.persistence.ddl-generation" value="drop-and-create-tables"/> | ||||
|             <property name="javax.persistence.logging.level" value="INFO"/> | ||||
|             <property name="jakarta.persistence.jdbc.user" value="root"/> | ||||
|             <property name="jakarta.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/> | ||||
|             <property name="jakarta.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/HIBERTEST"/> | ||||
|             <property name="jakarta.persistence.ddl-generation" value="drop-and-create-tables"/> | ||||
|             <property name="jakarta.persistence.logging.level" value="INFO"/> | ||||
|             <property name="hibernate.show_sql" value="false"/> | ||||
|             <property name="hibernate.cache.use_second_level_cache" value="false"/> | ||||
|             <property name="hibernate.cache.use_query_cache" value="false"/> | ||||
|  | ||||
| @ -17,7 +17,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; | ||||
| import org.springframework.test.context.support.AnnotationConfigContextLoader; | ||||
| import org.springframework.transaction.annotation.Transactional; | ||||
| 
 | ||||
| import javax.annotation.Resource; | ||||
| import jakarta.annotation.Resource; | ||||
| import java.util.Arrays; | ||||
| import java.util.Collections; | ||||
| import java.util.List; | ||||
|  | ||||
| @ -11,7 +11,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; | ||||
| import org.springframework.test.context.support.AnnotationConfigContextLoader; | ||||
| import org.springframework.transaction.annotation.Transactional; | ||||
| 
 | ||||
| import javax.annotation.Resource; | ||||
| import jakarta.annotation.Resource; | ||||
| 
 | ||||
| import java.util.Arrays; | ||||
| import java.util.List; | ||||
|  | ||||
| @ -7,13 +7,13 @@ import static org.junit.Assert.assertThat; | ||||
| 
 | ||||
| import java.util.List; | ||||
| 
 | ||||
| import javax.persistence.EntityManager; | ||||
| import javax.persistence.PersistenceContext; | ||||
| import javax.persistence.Query; | ||||
| import javax.persistence.TypedQuery; | ||||
| import javax.persistence.criteria.CriteriaBuilder; | ||||
| import javax.persistence.criteria.CriteriaQuery; | ||||
| import javax.persistence.criteria.Root; | ||||
| import jakarta.persistence.EntityManager; | ||||
| import jakarta.persistence.PersistenceContext; | ||||
| import jakarta.persistence.Query; | ||||
| import jakarta.persistence.TypedQuery; | ||||
| import jakarta.persistence.criteria.CriteriaBuilder; | ||||
| import jakarta.persistence.criteria.CriteriaQuery; | ||||
| import jakarta.persistence.criteria.Root; | ||||
| 
 | ||||
| import com.baeldung.config.PersistenceJPAConfig; | ||||
| import com.baeldung.persistence.model.Foo; | ||||
|  | ||||
| @ -2,13 +2,13 @@ package com.baeldung.persistence.service; | ||||
| 
 | ||||
| import java.util.List; | ||||
| 
 | ||||
| import javax.persistence.EntityManager; | ||||
| import javax.persistence.PersistenceContext; | ||||
| import javax.persistence.Query; | ||||
| import javax.persistence.TypedQuery; | ||||
| import javax.persistence.criteria.CriteriaBuilder; | ||||
| import javax.persistence.criteria.CriteriaQuery; | ||||
| import javax.persistence.criteria.Root; | ||||
| import jakarta.persistence.EntityManager; | ||||
| import jakarta.persistence.PersistenceContext; | ||||
| import jakarta.persistence.Query; | ||||
| import jakarta.persistence.TypedQuery; | ||||
| import jakarta.persistence.criteria.CriteriaBuilder; | ||||
| import jakarta.persistence.criteria.CriteriaQuery; | ||||
| import jakarta.persistence.criteria.Root; | ||||
| 
 | ||||
| import com.baeldung.config.PersistenceJPAConfig; | ||||
| import com.baeldung.persistence.model.Bar; | ||||
|  | ||||
| @ -5,9 +5,9 @@ import static org.junit.Assert.assertNull; | ||||
| 
 | ||||
| import java.util.List; | ||||
| 
 | ||||
| import javax.persistence.EntityManager; | ||||
| import javax.persistence.PersistenceContext; | ||||
| import javax.persistence.Query; | ||||
| import jakarta.persistence.EntityManager; | ||||
| import jakarta.persistence.PersistenceContext; | ||||
| import jakarta.persistence.Query; | ||||
| 
 | ||||
| import com.baeldung.config.PersistenceJPAConfig; | ||||
| import com.baeldung.persistence.model.Foo; | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user