when using jpa specification along with hibernate below error is occuring i have created one to one relation between course and courseMaterial and started the application but it's not working due to below error
Exception encountered during context initialization - cancelling refresh attempt: .springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Could not determine recommended JdbcType for Java type 'com.example.JpaRevision.repository.courseRepository'
below is the code from courseRepository
package com.example.JpaRevision.repository;
import .springframework.data.jpa.repository.JpaRepository;
import .springframework.stereotype.Repository;
import com.example.JpaRevision.entity.course;
@Repository
public interface courseRepository extends JpaRepository<course,Long>{
}
below is the code from courseMaterialRepository
package com.example.JpaRevision.repository;
import .springframework.data.jpa.repository.JpaRepository;
import .springframework.stereotype.Repository;
import com.example.JpaRevision.entity.courseMaterial;
@Repository
public interface courseMaterialRepository extends JpaRepository<courseMaterial,Long>{
}
below is the entity class created for courseMaterial
package com.example.JpaRevision.entity;
import .springframework.beans.factory.annotation.Autowired;
import com.example.JpaRevision.repository.courseMaterialRepository;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.OneToOne;
import jakarta.persistence.SequenceGenerator;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Entity
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class courseMaterial {
@Autowired
private courseMaterialRepository coureMat;
@Id
@SequenceGenerator(
name="courseMaterial_Sequence",
sequenceName="courseMaterial_Sequence"
)
@GeneratedValue(
strategy=GenerationType.SEQUENCE,
generator="courseMaterial_Sequence"
)
private Long courseMaterialId;
private String courseMaterialName;
private String courseMaterialPrice;
@OneToOne()
@JoinColumn(
name="course_id",
referencedColumnName="courseId"
)
private course courseData;
}
below is the entity class for course
package com.example.JpaRevision.entity;
import .springframework.beans.factory.annotation.Autowired;
import com.example.JpaRevision.repository.courseRepository;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.SequenceGenerator;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Entity
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class course {
@Autowired
private courseRepository coureRepo;
@Id
@SequenceGenerator(
name="course_sequence",
sequenceName="course_sequence",
allocationSize=1
)
@GeneratedValue(strategy=GenerationType.SEQUENCE,
generator="course_sequence")
private Long courseId;
private String courseName;
private double costPrice;
//private courseMaterial courseMat;
}
below is the pom.xml file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns=".0.0" xmlns:xsi=";
xsi:schemaLocation=".0.0 .0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.4.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>JpaRevision</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>JpaRevision</name>
<description>Demo project for Spring Boot</description>
<url/>
<licenses>
<license/>
</licenses>
<developers>
<developer/>
</developers>
<scm>
<connection/>
<developerConnection/>
<tag/>
<url/>
</scm>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>