Caused by: java.lang.IllegalArgumentException: Not a managed type: class…
- User
Caused by: java.lang.IllegalArgumentException: Not a managed type: class com.ncs.core.model.AcqOperationTurnover at <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>//org.hibernate.metamodel.internal.MetamodelImpl.managedType(MetamodelImpl.java:552) at deployment.acq-core-web.war//org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation.(JpaMetamodelEntityInformation.java:71) at deployment.acq-core-web.war//org.springframework.data.jpa.repository.support.JpaEntityInformationSupport.getEntityInformation(JpaEntityInformationSupport.java:68) at deployment.acq-core-web.war//org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getEntityInformation(JpaRepositoryFactory.java:197) at deployment.acq-core-web.war//org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:130) at deployment.acq-core-web.war//org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:111) at deployment.acq-core-web.war//org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:198) at deployment.acq-core-web.war//org.springframework.data.jpa.repository.cdi.JpaRepositoryBean.create(JpaRepositoryBean.java:73) at deployment.acq-core-web.war//org.springframework.data.repository.cdi.CdiRepositoryBean.create(CdiRepositoryBean.java:374) at deployment.acq-core-web.war//org.springframework.data.repository.cdi.CdiRepositoryBean.create(CdiRepositoryBean.java:172) at deployment.acq-core-web.war//org.springframework.data.repository.cdi.CdiRepositoryBean.initialize(CdiRepositoryBean.java:157) at deployment.acq-core-web.war//org.springframework.data.repository.cdi.CdiRepositoryExtensionSupport.afterDeploymentValidation(CdiRepositoryExtensionSupport.java:153) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>//org.jboss.weld.injection.StaticMethodInjectionPoint.invoke(StaticMethodInjectionPoint.java:95) at <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>//org.jboss.weld.injection.MethodInvocationStrategy$SpecialParamPlusBeanManagerStrategy.invoke(MethodInvocationStrategy.java:187) at <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>//org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:330) at <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>//org.jboss.weld.event.ExtensionObserverMethodImpl.sendEvent(ExtensionObserverMethodImpl.java:123) at <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>//org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:308) at <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>//org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:286) at javax.enterprise.api//javax.enterprise.inject.spi.ObserverMethod.notify(ObserverMethod.java:124) at <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>//org.jboss.weld.util.Observers.notify(Observers.java:166) at <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>//org.jboss.weld.event.ObserverNotifier.notifySyncObservers(ObserverNotifier.java:285) at <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>//org.jboss.weld.event.ObserverNotifier.notify(ObserverNotifier.java:273) at <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>//org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:177) at <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>//org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:171) at <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>//org.jboss.weld.bootstrap.events.AbstractContainerEvent.fire(AbstractContainerEvent.java:53) at <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>//org.jboss.weld.bootstrap.events.AbstractDeploymentContainerEvent.fire(AbstractDeploymentContainerEvent.java:35)
- Assistant
The error message suggests that the class
com.ncs.core.model.AcqOperationTurnoveris not a managed entity type in the Hibernate metamodel. This means that Hibernate cannot recognize this class as an entity that can be persisted in the database.To fix this issue, you need to ensure that the
AcqOperationTurnoverclass is properly annotated as an entity. Make sure that it is annotated with the@Entityannotation from thejavax.persistencepackage. Additionally, check that the package containing the entity is scanned by the Spring Data JPA configuration.If you have already annotated the
AcqOperationTurnoverclass properly, make sure that the entity class is included in the list of classes to be scanned by Hibernate. You can do this by specifying thepackagesToScanproperty in your Spring Data JPA configuration.If the issue still persists, double check that the class is in the correct package and that there are no typos in the package and class names used in the configuration.
Finally, ensure that the required dependencies for Hibernate and Spring Data JPA are properly included in your project's dependencies.
- User
что за ошибка?
- Assistant
Ошибка
java.lang.IllegalArgumentException: Not a managed type: class com.ncs.core.model.AcqOperationTurnoverвозникает, когда Hibernate не может распознать классcom.ncs.core.model.AcqOperationTurnoverкак управляемую сущность.Это может произойти, если класс не имеет аннотации
@Entityиз пакетаjavax.persistence, указывающей, что класс является сущностью, которую можно сохранять в базе данных.Чтобы исправить эту ошибку, необходимо убедиться, что класс
AcqOperationTurnoverправильно аннотирован как сущность. Удостоверьтесь, что у класса есть аннотация@Entityи что пакет, содержащий класс, сканируется конфигурацией Spring Data JPA.Если класс уже правильно аннотирован, также проверьте, что класс сущности включен в список классов, сканируемых Hibernate. Для этого можно указать свойство
packagesToScanв конфигурации Spring Data JPA.Если проблема все еще не устранена, убедитесь, что класс находится в правильном пакете и что в конфигурации нет опечаток в именах пакетов и классов.
Наконец, проверьте, что все необходимые зависимости для Hibernate и Spring Data JPA правильно указаны в зависимостях вашего проекта.
- User
как сделать каждую минуту?@Schedule(hour = "2", persistent = false) public void refreshTurnover() { acqOperationTurnoverService.clearOldData(); }
- Assistant
To schedule a method to run every minute, you can use the
@Scheduledannotation along with thecronattribute. You can specify the cron expression to represent a scheduling pattern for the method.In your case, you can modify your code as follows:
@Scheduled(cron = "0 * * * * *") // Run every minute public void refreshTurnover() { acqOperationTurnoverService.clearOldData(); }With the
cron = "0 * * * * *"expression, the method will be scheduled to run at the beginning of every minute, i.e., at 00 seconds of each minute.Make sure that you have the necessary dependencies and the
@EnableSchedulingannotation is present in your configuration class. Also, ensure that the class containing this method is a Spring component or bean, so that it can be detected and scheduled by the Spring scheduler.