3
votes

i have a 2 custom class, OzBakim and GunlukEtkinlik. these classes not entity. I need to use these classes in entities.

But I get an error:

Error creating bean with name 'entityManagerFactory' defined in class path resource

How can I solve the problem?

What i got so far:

@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
}

Error :

2017-06-23 13:53:19.791 WARN 12832 --- [ main] o.s.w.c.s.GenericWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory

2017-06-23 13:53:19.799 WARN 12832 --- [ main] o.s.boot.SpringApplication : Error handling failed (Error creating bean with name 'delegatingApplicationListener' defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration': Initialization of bean failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'org.springframework.context.annotation.ConfigurationClassPostProcessor.importRegistry' available)

1
and that exception will have a nested exception that tells you real reason. - Neil Stockton
Please write full stack trace. - ooozguuur
@ozgur Yazıyorum şimdi güncellemeyle. - Erdem Aydemir
@NeilStockton i updated. - Erdem Aydemir
The stack trace? The output of "e.printStackTrace" ... - Neil Stockton

1 Answers

1
votes

I found the mistake. : )

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

@Embeddable entity in @Entity class, which makes it to add columns for embedded entity in same table of @Entity class.

Repeated column name can't use.

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

and

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