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

时间:2017-06-23 09:43:46

标签: java spring jpa spring-boot spring-data-jpa

我有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
}

更新

@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:创建名称为'的bean时出错在类路径资源中定义的entityManagerFactory [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:错误处理失败(错误创建名为'delegatingApplicationListener'的bean在类路径资源中定义[org / springframework / security / config / annotation / web / configuration / WebSecurityConfiguration.class]: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 :(得分: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);
}