Home > database >  Upgrade from Spring Boot 2.7.2 to Spring Boot 3.0.0-SNAPSHOT:
Upgrade from Spring Boot 2.7.2 to Spring Boot 3.0.0-SNAPSHOT:

Time:08-15

code

package com.example.BLModel;

import org.hibernate.annotations.Type;

import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.MapsId;
import javax.persistence.Table;

@Entity
@Table(name = "email_template_custom")
public class EmailTemplateCustom {
    @EmbeddedId
    private EmailTemplateCustomId id;

    @MapsId("tenantId")
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @JoinColumn(name = "tenant_id", nullable = false)
    private Tenant tenant;

    @Column(name = "email_subject", nullable = false, length = 1000)
    private String emailSubject;

    @Column(name = "email_content")
    @Type(type = "org.hibernate.type.TextType")
    private String emailContent;

    public EmailTemplateCustomId getId() {
        return id;
    }

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

    public Tenant getTenant() {
        return tenant;
    }

    public void setTenant(Tenant tenant) {
        this.tenant = tenant;
    }

    public String getEmailSubject() {
        return emailSubject;
    }

    public void setEmailSubject(String emailSubject) {
        this.emailSubject = emailSubject;
    }

    public String getEmailContent() {
        return emailContent;
    }

    public void setEmailContent(String emailContent) {
        this.emailContent = emailContent;
    }

}

Error

D:\github\spring_jwt\src\main\java\com\example\BLModel\EmailTemplateCustom.java:29:11
java: cannot find symbol
  symbol:   method type()
  location: @interface org.hibernate.annotations.Type

enter image description here How to fix it?

CodePudding user response:

See the migration guide for Hibernate 6.0 to understand what you have to change in your code. In this particular case, you have to replace the @Type annotation with @JdbcTypeCode(SqlTypes.LONGVARCHAR)

  • Related