首页 文章

Spring Boot - 实体中的自定义类字段

提问于
浏览
2

我有一个2自定义类, OzBakimGunlukEtkinlik . 这些类不是实体 . 我需要在实体中使用这些类 .

但是我收到一个错误:

在类路径资源中定义名称为'entityManagerFactory'的bean时出错

我该如何解决这个问题?

到目前为止我得到了什么:

@Entity
@Table
@EntityListeners(AuditingEntityListener.class)
public class Rapor implements Serializable {

    @Id
    @SequenceGenerator(name = "RAPOR_SEQUENCE", sequenceName = "RAPOR_SEQUENCE", allocationSize = 1)
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "RAPOR_SEQUENCE")
    private Long id;

    @Embedded
    private OzBakim ozBakim;

    @Embedded
    private GunlukEtkinlik gunlukEtkinlik;

    private Date tarih;

//Set Get
}

UPDATE

@Embeddable
public class GunlukEtkinlik {
    private boolean anaDil;
    private boolean bahce;
    private boolean bilimDeney;
    private boolean drama;
    private boolean dans;
    private boolean fenDoga;
    private boolean gezi;
    private boolean gorselSanatlar;
    private boolean masaBasiEtkinlik;
    private boolean masal;
    private boolean matematik;
    private boolean mutfakEtkinlik;
    private boolean muzik;
    private boolean oyun;
    private boolean satranc;
    private boolean spor;
    private boolean ingilizce;
    private boolean digerDiller;
    private boolean yaraticiEtkinlik;
    private boolean ogretmenNotu;
//Set Get
}

@Embeddable
public class OzBakim {
    private int kahvalti;
    private int ogleYemegi;
    private int ikindiKahvaltisi;
    private int elYuzTuvaletTemizligi;
    private int okulFaaliyetleri;
    private int arkadasIletisim;
    private int ogleUykusu;
    private int ogretmenNotu;
    private int topluOgretmenNotu;
//Set Get
}

错误:

2017-06-23 13:53:19.791 WARN 12832 --- [main] oswcsGenericWebApplicationContext:在上下文初始化期间遇到异常 - 取消刷新尝试:org.springframework.beans.factory.BeanCreationException:创建名为'entityManagerFactory'的bean时出错在类路径资源中定义[org / springframework / boot / autoconfigure / orm / jpa / HibernateJpaAutoConfiguration.class]:调用init方法失败;嵌套异常是javax.persistence.PersistenceException:[PersistenceUnit:default]无法构建Hibernate SessionFactory 2017-06-23 13:53:19.799 WARN 12832 --- [main] osboot.SpringApplication:错误处理失败(创建bean时出错)在类路径资源[org / springframework / security / config / annotation / web / configuration / WebSecurityConfiguration.class]中定义的名称“delegatingApplicationListener”:bean实例化之前的BeanPostProcessor失败;嵌套异常是org.springframework.beans.factory.BeanCreationException:错误创建名为'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration'的bean:bean的初始化失败;嵌套异常是org.springframework.beans.factory.NoSuchBeanDefinitionException:没有名为'org.springframework.context.annotation.ConfigurationClassPostProcessor.importRegistry'的bean提供)

1 回答

  • 0

    我发现了错误 . :)

    Repeated column in mapping for entity: com.exam.model.Rapor column: ogretmen_notu (should be mapped with insert="false" update="false")
    

    @Entity类中的@Embeddable实体,它使嵌入式实体的列在@Entity类的同一个表中添加 .

    重复的列名不能使用 .

    @Embeddable
    public class GunlukEtkinlik {
        .
        .
        .
        private boolean ogretmenNotu;
    }
    

    @Embeddable
    public class OzBakim {
        .
        .
        .
        private int ogretmenNotu(You must change name);
    }
    

相关问题