- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有以下实体:
@Entity
public class Employee implements Serializable{
private static final long serialVersionUID = 3454567L;
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private int empId;
@Column
private String username;
public int getEmpId() {
return empId;
}
public void setEmpId(int empId) {
this.empId = empId;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
}
public class UserDAO implements UserDAOInterface{
@PersistenceContext(unitName = "MainPersistenceUnit")
private EntityManager em;
@Override
public void persist(Employee sdf) {
try {
em.persist(sdf);
} catch (Exception e) {
Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", e);
throw new RuntimeException(e);
}
}
}
Caused by: org.hibernate.PropertyAccessException: could not get a field value by reflection getter of com.mine.projs.library.entity.Employee.empId
at org.hibernate.property.DirectPropertyAccessor$DirectGetter.get(DirectPropertyAccessor.java:60)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:346)
at org.hibernate.persister.entity.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java:4746)
at org.hibernate.persister.entity.AbstractEntityPersister.isTransient(AbstractEntityPersister.java:4465)
at org.hibernate.engine.internal.ForeignKeys.isTransient(ForeignKeys.java:243)
at org.hibernate.event.internal.AbstractSaveEventListener.getEntityState(AbstractSaveEventListener.java:511)
at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:116)
at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:75)
at org.hibernate.internal.SessionImpl.firePersist(SessionImpl.java:811)
at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:784)
at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:789)
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:1181)
... 100 more
Info: HHH000204: Processing PersistenceUnitInfo [
name: MainPersistenceUnit
...]
Info: HHH000412: Hibernate Core {4.3.7.Final}
Info: HHH000206: hibernate.properties not found
Info: HHH000021: Bytecode provider name : javassist
Info: HCANN000001: Hibernate Commons Annotations {4.0.5.Final}
Info: HHH000400: Using dialect: org.hibernate.dialect.MySQL5InnoDBDialect
Info: HHH000397: Using ASTQueryTranslatorFactory
Info: HHH000227: Running hbm2ddl schema export
Info: Hibernate: drop table if exists Employee
Info: Hibernate: create table Employee (empId integer not null auto_increment, username varchar(255), primary key (empId)) ENGINE=InnoDB
Info: HHH000230: Schema export complete
Info: Portable JNDI names for EJB UserService: [java:global/Library/UserService, java:global/Library/UserService!com.mine.projs.library.service.interfaces.UserServiceInterface]
WARN: WELD-000411: Observer method [BackedAnnotatedMethod] private org.glassfish.jersey.gf.cdi.internal.CdiComponentProvider.processAnnotatedType(@Observes ProcessAnnotatedType<Object>) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
WARN: WELD-000411: Observer method [BackedAnnotatedMethod] public org.glassfish.jms.injection.JMSCDIExtension.processAnnotatedType(@Observes ProcessAnnotatedType<Object>) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
WARN: WELD-000411: Observer method [BackedAnnotatedMethod] org.glassfish.sse.impl.ServerSentEventCdiExtension.processAnnotatedType(@Observes ProcessAnnotatedType<Object>, BeanManager) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
Info: Initializing Mojarra 2.2.7 ( 20140610-1547 https://svn.java.net/svn/mojarra~svn/tags/2.2.7@13362) for context '/libr'
Info: Running on PrimeFaces 5.1
Info: Loading application [Library] at [/libr]
Info: Library was successfully deployed in 3,429 milliseconds.
Info: inside getAna
Info: inside Create User
Severe: exception caught
javax.persistence.PersistenceException: org.hibernate.PropertyAccessException: could not get a field value by reflection getter of com.mine.projs.library.entity.Employee.empId
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1763)
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1677)
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1683)
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:1187)
at com.sun.enterprise.container.common.impl.EntityManagerWrapper.persist(EntityManagerWrapper.java:287)
at com.mine.projs.library.dao.UserDAO.persist(UserDAO.java:20)
at com.mine.projs.library.service.UserService.createUSer(UserService.java:21)
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:483)
at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1081)
at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1153)
at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:4786)
at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:656)
at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:608)
at org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:46)
at org.jboss.weld.ejb.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:52)
at sun.reflect.GeneratedMethodAccessor103.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:883)
at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:608)
at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doCall(SystemInterceptorProxy.java:163)
at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundInvoke(SystemInterceptorProxy.java:140)
at sun.reflect.GeneratedMethodAccessor151.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:883)
at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:369)
at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:4758)
at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:4746)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:212)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:88)
at com.sun.proxy.$Proxy321.createUSer(Unknown Source)
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:483)
at org.jboss.weld.util.reflection.Reflections.invokeAndUnwrap(Reflections.java:414)
at org.jboss.weld.bean.proxy.EnterpriseBeanProxyMethodHandler.invoke(EnterpriseBeanProxyMethodHandler.java:127)
at org.jboss.weld.bean.proxy.EnterpriseTargetBeanInstance.invoke(EnterpriseTargetBeanInstance.java:56)
at org.jboss.weld.bean.proxy.InjectionPointPropagatingEnterpriseTargetBeanInstance.invoke(InjectionPointPropagatingEnterpriseTargetBeanInstance.java:65)
at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:100)
at com.mine.projs.library.service.UserServiceInterface$243194531$Proxy$_$$_Weld$EnterpriseProxy$.createUSer(Unknown Source)
at com.mine.projs.library.view.UserBean.getAna(UserBean.java:29)
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:483)
at javax.el.BeanELResolver.getValue(BeanELResolver.java:363)
at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
at com.sun.el.parser.AstValue.getValue(AstValue.java:140)
at com.sun.el.parser.AstValue.getValue(AstValue.java:204)
at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:226)
at org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:50)
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
at javax.faces.component.UICommand.getValue(UICommand.java:218)
at com.sun.faces.renderkit.html_basic.ButtonRenderer.encodeBegin(ButtonRenderer.java:119)
at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:864)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1854)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:456)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:133)
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:337)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:647)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:415)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:282)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:201)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:175)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:561)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.hibernate.PropertyAccessException: could not get a field value by reflection getter of com.mine.projs.library.entity.Employee.empId
at org.hibernate.property.DirectPropertyAccessor$DirectGetter.get(DirectPropertyAccessor.java:60)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:346)
at org.hibernate.persister.entity.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java:4746)
at org.hibernate.persister.entity.AbstractEntityPersister.isTransient(AbstractEntityPersister.java:4465)
at org.hibernate.engine.internal.ForeignKeys.isTransient(ForeignKeys.java:243)
at org.hibernate.event.internal.AbstractSaveEventListener.getEntityState(AbstractSaveEventListener.java:511)
at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:116)
at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:75)
at org.hibernate.internal.SessionImpl.firePersist(SessionImpl.java:811)
at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:784)
at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:789)
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:1181)
... 100 more
最佳答案
我有同样的问题。这个错误似乎是从 HB 4.3.6 开始的,并且一直存在,我正在尝试 4.3.10;结果相同。
在我看来,实体字段的访问方式在 HB 4.3.6+ 中发生了变化,可能与类加载器有关。在 HB 4.3.6 之前,将 DB 驱动程序 jar 文件嵌入到 ear 文件中可以正常工作(部署起来非常简单和干净)。 4.3.6以后不行了(class not found异常),现在驱动jar文件必须放在Glassfish的lib文件夹下。
胡安
关于hibernate - javax.persistence.PersistenceException : org. hibernate.PropertyAccessException : could not get a field value by reflection getter of Entity. id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27771440/
如果您有一个具有一些普通 get/set 属性的类,是否有任何理由在类方法中使用 getter,或者您应该只使用私有(private)成员变量?我认为关于setter(验证逻辑?)可能会有更多争论,但
我是 Android 编程的新手(~ 2 个月)有必要为几十个不同的变量设置 getter 吗? 例如—— //Yes I realise that this isn't 'dozens' publi
我是VUEX新手,在学习VUEX的同时搭建了一个测试应用。我已将我的 VUEX 存储拆分为多个模块,每个模块都有自己的 getter.js 文件。 Getters、 Action 、突变被导入到每个模
我有一项服务正在加载我想在多个组件之间共享的基本系统信息。 如果我在 getter 中创建一个 getter 方法 this 如果我不在服务中使用双箭头,则 getter 中的 this 成为组件的
tl;博士 如何从参数化的 getter 访问其他 getter? 通常可以使用this.myGetter ;但是参数化的 getter 被实现为箭头函数,其中 this未定义。 在 Pinia 中处
我第一次尝试做一些 OOP,这不是简单的练习,而是用 java 编写一个程序来存储有关人员的信息(如通讯录)。下面是我正在开发的名为 Person 的类的片段。 Person 将在将来的某个时间被其他
我在某处看到类似下面的内容,想知道它是什么意思。我知道他们是getter和setter,但是想知道为什么字符串Type是这样定义的。谢谢你帮助我。 public string Type { get;
Public class Example { private int number; public Example(int number){ this.number =
getter 应该只返回对象吗: public MyObject getMyObject() { return myObject; } 或者它应该复制它返回的对象并返回该副本? public
我目前正在处理大量数据输入,包括很多值,我希望在 getter 中接收这些值以供以后使用。 在编写了一些方法之后,我想知道仅使用一个 get 方法是否是一个更好的主意,并使用一个包含所有可能值的枚举类
我正在使用新的 Class Public Field Declarations可用 Chrome 72我遇到了这种真正奇怪的行为: class Extended { property = 5; }
我有一个这样的表达式 setter/getter : var expression = () => SomeInstance.Nr; 它被传递到一个方法中: public void AddExpres
我的一个类(class)中有以下 getter: get password(){ if(this._public) return null; var text = ""
我已经设法测试了与其他代码隔离的 Vuex getter。当 getter 依赖于其他 getter 时,我现在面临一些问题,请参见以下示例: getters.js export const gett
有时我的任务是查找 getter 返回的值中的某些嵌套 getter 是否具有某些属性。经典的 C++ 会是这样的: for (const auto& label: labels) for (co
我有一个像这样的基类“Parent”: using System; using System.Collections.Generic; using System.Text; namespace Con
我一直在努力了解 getter 和 setter,但没有深入了解。我读过 JavaScript Getters and Setters和 Defining Getters and Setters只是没
考虑一个简单的 Vue 博客: 我使用 Vuex 作为我的数据存储,我需要设置两个 getters :一个 getPost getter,用于通过 ID 检索 post,以及一个 listFeatur
我有一个 VueX 商店,有两个模块,user.js 和merchant.js,顶层是index.js。 user.js 中的 getter 是: 重构 const getters = { s
我正在尝试向 jsp 添加一个复选框以在进入站点之前接受条款和条件。尽管我有一个 getter 方法并且没有看到任何拼写错误,但我一直收到关于没有 getter 方法的相同错误。我不明白我错过了什么。
我是一名优秀的程序员,十分优秀!