Could not determine recommended JdbcType” error with Hibernate @Embeddable annotation

Issue:
I’m encountering an error while working with Hibernate annotations, specifically when using the @Embeddable annotation. The error message I’m receiving is:

Could not determine recommended JdbcType for Java type ‘com.jack.secondTrail.Certificate’

Context:
I’m utilizing Hibernate annotations, particularly @Embeddable, in my Java project. The @Embeddable annotation is used to indicate that a class is to be embedded into another entity. In my case, I have a class named Certificate that I intend to embed into another entity.

The whole code:

EmbedTable.java file

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>package com.jack.secondTrail;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import jakarta.persistence.Embeddable;
@Embeddable
public class EmbedTable {
public static void main(String[] args) {
//configuration
Configuration cfg = new Configuration();
cfg.configure();
SessionFactory factory = cfg.buildSessionFactory();
//1st student object
Student student1 = new Student();
student1.setId(1254);
student1.setName("Anuv Jain");
student1.setAddress("Mumbai");
//1st certificate obj for student 1
Certificate certificate = new Certificate();
certificate.setCourse("Java Development");
certificate.setCourse("5 months");
student1.setCerti(certificate);
//2nd student object
Student student2 = new Student();
student2.setId(1546);
student2.setName("Nakul Dhull");
student2.setAddress("Gurgaon");
//2nd certificate object for student 2
Certificate certificate2 = new Certificate();
certificate2.setCourse("API Design");
certificate2.setDuration("4 months");
student2.setCerti(certificate2);
//open session to changes
Session se = factory.openSession();
Transaction tx = se.beginTransaction(); //for saving..
se.save(student1);
se.save(student2);
tx.commit();
se.close();
factory.close();
}
}
</code>
<code>package com.jack.secondTrail; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.Transaction; import org.hibernate.cfg.Configuration; import jakarta.persistence.Embeddable; @Embeddable public class EmbedTable { public static void main(String[] args) { //configuration Configuration cfg = new Configuration(); cfg.configure(); SessionFactory factory = cfg.buildSessionFactory(); //1st student object Student student1 = new Student(); student1.setId(1254); student1.setName("Anuv Jain"); student1.setAddress("Mumbai"); //1st certificate obj for student 1 Certificate certificate = new Certificate(); certificate.setCourse("Java Development"); certificate.setCourse("5 months"); student1.setCerti(certificate); //2nd student object Student student2 = new Student(); student2.setId(1546); student2.setName("Nakul Dhull"); student2.setAddress("Gurgaon"); //2nd certificate object for student 2 Certificate certificate2 = new Certificate(); certificate2.setCourse("API Design"); certificate2.setDuration("4 months"); student2.setCerti(certificate2); //open session to changes Session se = factory.openSession(); Transaction tx = se.beginTransaction(); //for saving.. se.save(student1); se.save(student2); tx.commit(); se.close(); factory.close(); } } </code>
package com.jack.secondTrail;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;

import jakarta.persistence.Embeddable;

@Embeddable
public class EmbedTable {
    public static void main(String[] args) {

        //configuration     
        Configuration cfg = new Configuration();
        cfg.configure();
        SessionFactory factory = cfg.buildSessionFactory();
        
        //1st student object        
        Student student1 = new Student();
        student1.setId(1254);
        student1.setName("Anuv Jain");
        student1.setAddress("Mumbai");
        
        //1st certificate obj for student 1
        Certificate certificate = new Certificate();
        certificate.setCourse("Java Development");
        certificate.setCourse("5 months");
        student1.setCerti(certificate);
        
        
        //2nd student object 
        Student student2 = new Student();
        student2.setId(1546);
        student2.setName("Nakul Dhull");
        student2.setAddress("Gurgaon");
        
        //2nd certificate object for student 2
        Certificate certificate2 = new Certificate();
        certificate2.setCourse("API Design");
        certificate2.setDuration("4 months");
        student2.setCerti(certificate2);
        
        
        //open session to changes
        Session se = factory.openSession();
        Transaction tx = se.beginTransaction(); //for saving..
        
        se.save(student1);
        se.save(student2);
        
        tx.commit();
        
        se.close();
        factory.close();
        
        
    }
}

Certificate.java file:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>package com.jack.secondTrail;
public class Certificate {
private String course;
private String duration;
public String getCourse() {
return course;
}
public void setCourse(String course) {
this.course = course;
}
public String getDuration() {
return duration;
}
public void setDuration(String duration) {
this.duration = duration;
}
public Certificate(String course, String duration) {
super();
this.course = course;
this.duration = duration;
}
public Certificate() {
super();
// TODO Auto-generated constructor stub
}
}
</code>
<code>package com.jack.secondTrail; public class Certificate { private String course; private String duration; public String getCourse() { return course; } public void setCourse(String course) { this.course = course; } public String getDuration() { return duration; } public void setDuration(String duration) { this.duration = duration; } public Certificate(String course, String duration) { super(); this.course = course; this.duration = duration; } public Certificate() { super(); // TODO Auto-generated constructor stub } } </code>
package com.jack.secondTrail;

public class Certificate {
    
    private String course;
    private String duration;
    
    
    public String getCourse() {
        return course;
    }
    public void setCourse(String course) {
        this.course = course;
    }
    public String getDuration() {
        return duration;
    }
    public void setDuration(String duration) {
        this.duration = duration;
    }
    
    
    public Certificate(String course, String duration) {
        super();
        this.course = course;
        this.duration = duration;
    }
    public Certificate() {
        super();
        // TODO Auto-generated constructor stub
    }
    
}

Student Class:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>package com.jack.secondTrail;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
@Entity
public class Student {
@Id
private int id;
private String name;
private String address;
private Certificate certi;
public Student(int id, String name, String address, Certificate certi) {
super();
this.id = id;
this.name = name;
this.address = address;
this.certi = certi;
}
public Student() {
super();
// TODO Auto-generated constructor stub
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public Certificate getCerti() {
return certi;
}
public void setCerti(Certificate certi) {
this.certi = certi;
}
@Override
public String toString() {
// TODO Auto-generated method stub
return this.id+" : "+ this.name+" : "+ this.address;
}
}
</code>
<code>package com.jack.secondTrail; import jakarta.persistence.Entity; import jakarta.persistence.Id; import jakarta.persistence.Table; @Entity public class Student { @Id private int id; private String name; private String address; private Certificate certi; public Student(int id, String name, String address, Certificate certi) { super(); this.id = id; this.name = name; this.address = address; this.certi = certi; } public Student() { super(); // TODO Auto-generated constructor stub } public int getId() { return id; } public void setId(int id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getAddress() { return address; } public void setAddress(String address) { this.address = address; } public Certificate getCerti() { return certi; } public void setCerti(Certificate certi) { this.certi = certi; } @Override public String toString() { // TODO Auto-generated method stub return this.id+" : "+ this.name+" : "+ this.address; } } </code>
package com.jack.secondTrail;

import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;

@Entity
public class Student {
    
    @Id
    private int id;
    private String name;
    private String address;

    private Certificate certi;
    
    
    public Student(int id, String name, String address, Certificate certi) {
        super();
        this.id = id;
        this.name = name;
        this.address = address;
        this.certi = certi;
    }

    public Student() {
        super();
        // TODO Auto-generated constructor stub
    }

    public int getId() {
        return id;
    }


    public void setId(int id) {
        this.id = id;
    }


    public String getName() {
        return name;
    }


    public void setName(String name) {
        this.name = name;
    }


    public String getAddress() {
        return address;
    }


    public void setAddress(String address) {
        this.address = address;
    }


    public Certificate getCerti() {
        return certi;
    }


    public void setCerti(Certificate certi) {
        this.certi = certi;
    }


    @Override
    public String toString() {
        // TODO Auto-generated method stub
        return this.id+" : "+ this.name+" : "+ this.address;
    }

}

New contributor

Hemant Garg is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật