Uknown entity error when saving an instance of a class

https://gist.github.com/soforiokyere/59d6e68ef22c7026893ac6da773fae24

Why you don’t use payroll repository in order to save the entity?
Instead get entitymanager etc you should be ok using Repository

I used the repository and had the same error of unknown entity

Did you change the table structure recently?
The mapping exception usually is related for the mapping for the entity maybe a field mismapped or a relation

No please. The only thing i did was to write the business logic. The database and java repositories are auto generated by axelor.

Ok, I guess the entity you’re passing doesn’t adhere to the Entity structure.
I would double-check all entity fields and data.
Another solution would be to change logging config to TRACE in order to see deeper in the error

this is the stacktrace error

java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.axelor.meta.ActionHandler.call(ActionHandler.java:185)
at com.axelor.meta.schema.actions.ActionMethod.evaluate(ActionMethod.java:76)
at com.axelor.meta.schema.actions.Action.execute(Action.java:98)
at com.axelor.meta.schema.actions.Action.wrap(Action.java:107)
at com.axelor.meta.schema.actions.ActionGroup.evaluate(ActionGroup.java:230)
at com.axelor.meta.schema.actions.Action.execute(Action.java:95)
at com.axelor.meta.schema.actions.Action.wrap(Action.java:107)
at com.axelor.meta.ActionHandler.execute(ActionHandler.java:453)
at com.axelor.meta.ActionExecutor.execute(ActionExecutor.java:43)
at com.axelor.meta.ActionExecutor$$EnhancerByGuice$$fd4b78b8.CGLIB$execute$0()
at com.axelor.meta.ActionExecutor$$EnhancerByGuice$$fd4b78b8$$FastClassByGuice$$65846e73.invoke()
at com.google.inject.internal.cglib.proxy.$MethodProxy.invokeSuper(MethodProxy.java:228)
at com.google.inject.internal.InterceptorStackCallback$InterceptedMethodInvocation.proceed(InterceptorStackCallback.java:76)
at com.axelor.rpc.ResponseInterceptor.invoke(ResponseInterceptor.java:56)
at com.google.inject.internal.InterceptorStackCallback$InterceptedMethodInvocation.proceed(InterceptorStackCallback.java:78)
at com.google.inject.internal.InterceptorStackCallback.intercept(InterceptorStackCallback.java:54)
at com.axelor.meta.ActionExecutor$$EnhancerByGuice$$fd4b78b8.execute()
at com.axelor.web.service.ActionService.execute(ActionService.java:107)
at com.axelor.web.service.ActionService$$EnhancerByGuice$$6e3a19da.CGLIB$execute$0()
at com.axelor.web.service.ActionService$$EnhancerByGuice$$6e3a19da$$FastClassByGuice$$85164d8.invoke()
at com.google.inject.internal.cglib.proxy.$MethodProxy.invokeSuper(MethodProxy.java:228)
at com.google.inject.internal.InterceptorStackCallback$InterceptedMethodInvocation.proceed(InterceptorStackCallback.java:76)
at com.axelor.rpc.RequestFilter.invoke(RequestFilter.java:55)
at com.google.inject.internal.InterceptorStackCallback$InterceptedMethodInvocation.proceed(InterceptorStackCallback.java:78)
at com.axelor.rpc.ResponseInterceptor.invoke(ResponseInterceptor.java:65)
at com.google.inject.internal.InterceptorStackCallback$InterceptedMethodInvocation.proceed(InterceptorStackCallback.java:78)
at com.google.inject.internal.InterceptorStackCallback.intercept(InterceptorStackCallback.java:54)
at com.axelor.web.service.ActionService$$EnhancerByGuice$$6e3a19da.execute()
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:140)
at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:294)
at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:248)
at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:235)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:398)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:205)
at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:228)
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:89)
at com.axelor.db.tenants.AbstractTenantFilter.doFilter(AbstractTenantFilter.java:70)
at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:82)
at org.apache.shiro.guice.web.SimpleFilterChain.doFilter(SimpleFilterChain.java:44)
at io.buji.pac4j.filter.SecurityFilter.lambda$doFilter$0(SecurityFilter.java:86)
at org.pac4j.core.engine.DefaultSecurityLogic.perform(DefaultSecurityLogic.java:140)
at com.axelor.auth.pac4j.AuthPac4jModule$AxelorSecurityFilter$1.perform(AuthPac4jModule.java:479)
at com.axelor.auth.pac4j.AuthPac4jModule$AxelorSecurityFilter$1.perform(AuthPac4jModule.java:463)
at io.buji.pac4j.filter.SecurityFilter.doFilter(SecurityFilter.java:84)
at org.apache.shiro.guice.web.SimpleFilterChain.doFilter(SimpleFilterChain.java:41)
at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:387)
at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:82)
at com.axelor.app.internal.AppFilter.doFilter(AppFilter.java:94)
at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:82)
at com.google.inject.persist.PersistFilter.doFilter(PersistFilter.java:94)
at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:82)
at com.axelor.db.tenants.AbstractTenantFilter.doFilter(AbstractTenantFilter.java:70)
at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:82)
at com.axelor.web.servlet.CorsFilter.doFilter(CorsFilter.java:137)
at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:82)
at com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:121)
at com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:133)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:543)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:615)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:818)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1627)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalArgumentException: Unknown entity: com.axelor.apps.payroll.db.PayrollComponent$ByteBuddy$DKT0ZlHS
at org.hibernate.internal.SessionImpl.firePersist(SessionImpl.java:784)
at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:765)
at com.axelor.apps.payroll.service.PayrollServiceImplementation.processEmployeeDataForm(PayrollServiceImplementation.java:79)
at com.axelor.apps.payroll.web.PayrollController.processEmployeeDataForm(PayrollController.java:50)
… 94 more

Did you try debugging this point?

I am late in the party, but you are missing one small step, fetch the entity before you pass it to service

in your gistfile1.txt on line 20

1 « J'aime »

Can how do i fetch the entity please

see if it help you

1 « J'aime »

This really helps. No errors. But I can’t see the new I have created in my postgres database

can you share few lines?

of what please ??

The updated code is here https://gist.github.com/soforiokyere/59d6e68ef22c7026893ac6da773fae24

on which line you created new entry ?

Line 51 of payrollImplementation

you tried debugger where it is going ?

Your code updates the values in the current record. I want to create a new record entirely