Solucionado (ver solução)
Solucionado
(ver solução)
8
respostas

Estou recebendo os seguintes erros

Não está achando minha migration e fala que tem algo deprecated:

2022-11-14T12:47:07.695-03:00 INFO 1796 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed. 2022-11-14T12:47:07.807-03:00 INFO 1796 --- [ restartedMain] o.f.c.i.database.base.BaseDatabaseType : Database: jdbc:mysql://localhost/vollmed_api (MySQL 8.0) 2022-11-14T12:47:08.516-03:00 INFO 1796 --- [ restartedMain] o.f.core.internal.command.DbValidate : Successfully validated 0 migrations (execution time 00:00.097s) 2022-11-14T12:47:08.517-03:00 WARN 1796 --- [ restartedMain] o.f.core.internal.command.DbValidate : No migrations found. Are your locations set up correctly? 2022-11-14T12:47:08.581-03:00 INFO 1796 --- [ restartedMain] o.f.core.internal.command.DbMigrate : Current version of schema vollmed_api: << Empty Schema >> 2022-11-14T12:47:08.587-03:00 INFO 1796 --- [ restartedMain] o.f.core.internal.command.DbMigrate : Schema vollmed_api is up to date. No migration necessary. 2022-11-14T12:47:08.983-03:00 INFO 1796 --- [ restartedMain] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default] 2022-11-14T12:47:09.294-03:00 INFO 1796 --- [ restartedMain] org.hibernate.Version : HHH000412: Hibernate ORM core version 6.1.5.Final 2022-11-14T12:47:09.775-03:00 WARN 1796 --- [ restartedMain] org.hibernate.orm.deprecation : HHH90000021: Encountered deprecated setting [javax.persistence.sharedCache.mode], use [jakarta.persistence.sharedCache.mode] instead 2022-11-14T12:47:10.331-03:00 INFO 1796 --- [ restartedMain] SQL dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect 2022-11-14T12:47:10.668-03:00 ERROR 1796 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Failed to initialize JPA EntityManagerFactory: Entity 'med.voll.api.medico.Medico' has no identifier (every '@Entity' class must declare or inherit at least one '@Id' or '@EmbeddedId' property) 2022-11-14T12:47:10.669-03:00 WARN 1796 --- [ restartedMain] ConfigServletWebServerApplicationContext : 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/HibernateJpaConfiguration.class]: Entity 'med.voll.api.medico.Medico' has no identifier (every '@Entity' class must declare or inherit at least one '@Id' or '@EmbeddedId' property) 2022-11-14T12:47:10.673-03:00 INFO 1796 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...

8 respostas

Oi Henrique olhei o artigo que você compartilhou comigo mas não entendi. Meu projeto baixou o PJA 3 e não 2, não tenho o arquivo persisten.xml, uso o pom.xml e não tenho nenhuma configuração cacheable ou no projeto. Então não sei o que fiz de errado ainda ou como corrigir. Tentei seguir todos os passos das aulas. Antes até tentei com Eclipse e PostgreSQL, mas não deu certo. Refiz o projeto com IntelliJ e Mysql 8.

Oi Felipe,

Provavelmente você deve ter criado uma pasta chamada db.migration ao ínves de criar a pasta db e dentro dela a pasta migration.

sim Rodrigo esse problema consegui identificar. O outro que ainda

Qual o outro erro?

2022-11-14T12:47:09.294-03:00 INFO 1796 --- [ restartedMain] org.hibernate.Version : HHH000412: Hibernate ORM core version 6.1.5.Final 2022-11-14T12:47:09.775-03:00 WARN 1796 --- [ restartedMain] org.hibernate.orm.deprecation : HHH90000021: Encountered deprecated setting [javax.persistence.sharedCache.mode], use [jakarta.persistence.sharedCache.mode] instead 2022-11-14T12:47:10.331-03:00 INFO 1796 --- [ restartedMain] SQL dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect 2022-11-14T12:47:10.668-03:00 ERROR 1796 --j.LocalContainerEntityManagerFactoryBean : Failed to initialize JPA EntityManagerFactory: Entity 'med.voll.api.medico.Medico' has no identifier (every '@Entity' class must declare or inherit at least one '@Id' or '@EmbeddedId' property) 2022-11-14T12:47:10.669-03:00 WARN 1796 --- [ restartedMain] ConfigServletWebServerApplicationContext : 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/HibernateJpaConfiguration.class]: Entity 'med.voll.api.medico.Medico' has no identifier (every '@Entity' class must declare or inherit at least one '@Id' orEmbeddedId' property) 2022-11-14T12:47:10.669-03:00 WARN 1796 --- [ restartedMain] ConfigServletWebServerApplicationContext : 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/HibernateJpaConfiguration.class]: Entity 'med.voll.api.medico.Medico' has no identifier (every '@Entity' class must declare or inherit at least one '@Id' or '@EmbeddedId' property) 2022-11-14T12:47:10.673-03:00 INFO 1796 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...

solução!

Entity 'med.voll.api.medico.Medico' has no identifier (every '@Entity' class must declare or inherit at least one '@Id' or '@EmbeddedId' property

Verifica se na sua classe Medico o atributo id está anotado com @Id da jpa(pacote jakarta.persistence)

Bem observado Prof. Rodrigo! obrigado pela ajuda!