HHH000122:类中的非法参数异常:ConsumerAgentAccount,属性的获取方法:id



救命!在对这个网站和一般的互联网进行了大量研究之后,我一直无法找到解决方案。我有一个Hibernate 4.3.6/Glassfish 4.0项目,它部署得很好,但是当我尝试将新对象保存到数据库中时会抛出IllegalArgumentException。我过去曾在其他服务器上使用过此设置,没有任何问题,所以再次,我不知所措。

这个问题的核心有三个实体:

    @Entity
    @Cacheable(false)
    public class ConsumerAgentAccount implements Serializable
    {
        private static final long serialVersionUID = 6862398628955419461L;
        private long id = 0L;
        private Account account = null;
        private String firstName = null;
        private String lastName = null;
        private boolean active = true;
        private long bornOn = 0L;
        private ConsumerAccount consumerAccount;
        public ConsumerAgentAccount() { super(); }
        @PrePersist
        private void onPersist()
        {
            bornOn = System.currentTimeMillis();
        }
        @Id
        @GeneratedValue(strategy=GenerationType.IDENTITY)
        public long getId()
        {
            return id;
        }
        public void setId(long id)
        {
            this.id = id;
        }
        @Embedded
        public Account getAccount()
        {
            return account;
        }
        public void setAccount(Account account)
        {
            this.account = account;
        }
        @Column(nullable=false, length=50)
        public String getFirstName()
        {
            return firstName;
        }
        public void setFirstName(String firstName)
        {
            this.firstName = firstName;
        }
        @Column(nullable=false, length=50)
        public String getLastName()
        {
            return lastName;
        }
        public void setLastName(String lastName)
        {
            this.lastName = lastName;
        }
        @Column(nullable=false)
        public boolean isActive()
        {
            return active;
        }
        public void setActive(boolean active)
        {
            this.active = active;
        }
        @Column(nullable=false, updatable=false)
        public long getBornOn()
        {
            return this.bornOn;
        }
        public void setBornOn(long bornOn)
        {
            this.bornOn = bornOn;
        }
        @ManyToOne(cascade=CascadeType.ALL, fetch=FetchType.EAGER, optional=false)
        public ConsumerAccount getConsumerAccount()
        {
            return consumerAccount;
        }
        public void setConsumerAccount(ConsumerAccount consumerAccount)
        {
            this.consumerAccount = consumerAccount;
        }
    }
@Embeddable
public class Account
{
    private String email = null;
    private String password = null;
    public Account() { super(); }
    public Account(String email, String password)
    {
        this.email = email;
        this.password = password;
    }
    @Column(nullable=false, length=100)
    public String getEmail()
    {
        return email;
    }
    public void setEmail(String email)
    {
        this.email = email;
    }
    @Column(nullable=false, length=20)
    public String getPassword()
    {
        return password;
    }
    public void setPassword(String password)
    {
        this.password = password;
    }
}
@Entity
@Cacheable(false)
public class ConsumerAccount implements Serializable
{
    private static final long serialVersionUID = -3886143395284500664L;
    private long id = 0L;
    private Account account = null;
    private String name = null;
    private boolean active = true;
    private long bornOn = 0L;
    private List<ConsumerAgentAccount> consumerAgentAccounts = null;
    private List<WebFormProfile> webFormProfiles = null;
    public ConsumerAccount() { super(); }
    @PrePersist
    private void onPersist()
    {
        bornOn = System.currentTimeMillis();
    }
    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    public long getId()
    {
        return id;
    }
    public void setId(long id)
    {
        this.id = id;
    }
    @Embedded
    public Account getAccount()
    {
        return account;
    }
    public void setAccount(Account account)
    {
        this.account = account;
    }
    @Column(nullable=false, length=75)
    public String getName()
    {
        return name;
    }
    public void setName(String name)
    {
        this.name = name;
    }
    @Column(nullable=false)
    public boolean isActive()
    {
        return active;
    }
    public void setActive(boolean active)
    {
        this.active = active;
    }
    @Column(nullable=false, updatable=false)
    public long getBornOn()
    {
        return this.bornOn;
    }
    public void setBornOn(long bornOn)
    {
        this.bornOn = bornOn;
    }
    @OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="consumerAccount")
    public List<ConsumerAgentAccount> getConsumerAgentAccounts()
    {
        System.out.println("getconsumeragentaccounts");
        return consumerAgentAccounts;
    }
    public void setConsumerAgentAccounts(List<ConsumerAgentAccount> consumerAgentAccounts)
    {
        this.consumerAgentAccounts = consumerAgentAccounts;
    }
    @OneToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER, mappedBy="consumerAccount")
    public List<WebFormProfile> getWebFormProfiles()
    {
        return webFormProfiles;
    }
    public void setWebFormProfiles(List<WebFormProfile> webFormProfiles)
    {
        this.webFormProfiles = webFormProfiles;
    }
}

这是我的坚持.xml:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
    <persistence-unit name="inserteck_punit" transaction-type="JTA">
        <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
        <jta-data-source>jdbc/inserteck</jta-data-source>
        <mapping-file>META-INF/namedqueries.xml</mapping-file>
        <class>com.blushiftss.inserteck.entities.ConsumerAccount</class>
        <class>com.blushiftss.inserteck.entities.ConsumerAgentAccount</class>
        <class>com.blushiftss.inserteck.entities.ProfileField</class>
        <class>com.blushiftss.inserteck.entities.ProviderAccount</class>
        <class>com.blushiftss.inserteck.entities.ProviderProfile</class>
        <class>com.blushiftss.inserteck.entities.ProviderProfileMessage</class>
        <class>com.blushiftss.inserteck.entities.SuggestedWebFormFieldMapping</class>
        <class>com.blushiftss.inserteck.entities.WebFormField</class>
        <class>com.blushiftss.inserteck.entities.WebFormFieldMapping</class>
        <class>com.blushiftss.inserteck.entities.WebFormProfile</class>
        <class>com.blushiftss.inserteck.entities.embeds.Account</class>
        <class>com.blushiftss.inserteck.entities.embeds.Address</class>
        <class>com.blushiftss.inserteck.entities.embeds.EducationInfo</class>
        <class>com.blushiftss.inserteck.entities.embeds.FinancialInfo</class>
        <class>com.blushiftss.inserteck.entities.embeds.PersonalInfo</class>
        <class>com.blushiftss.inserteck.entities.embeds.SensitiveInfo</class>
        <class>com.blushiftss.inserteck.entities.embeds.WorkInfo</class>
        <exclude-unlisted-classes>true</exclude-unlisted-classes>
        <shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode>
        <properties>
            <property name="hibernate.show_sql" value="true"/>
            <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect"/>
            <property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.SunOneJtaPlatform"/>
            <property name="hibernate.ejb.entitymanager_factory_name" value="EJB.EMF.ITK"/>
            <property name="hibernate.hbm2ddl.auto" value="update"/>
            <property name="hibernate.generate_statistics" value="false"/>
            <property name="hibernate.cache.use_second_level_cache" value="false"/>
            <property name="hibernate.cache.use_query_cache" value="false"/>
        </properties>
    </persistence-unit>
</persistence>

这是我的一个 EJB 中的代码块,导致错误:

        ConsumerAccount consumerAccount = new ConsumerAccount();
        consumerAccount.setName("blah Enterprises, LLC.");
        consumerAccount.setActive(true);
        consumerAccount.setAccount(new Account("blah@blah.com", "blahblah"));
        consumerAccount.setConsumerAgentAccounts(new ArrayList<ConsumerAgentAccount>(0));
        consumerAccount.setWebFormProfiles(new ArrayList<WebFormProfile>(0));
        ConsumerAgentAccount consumerAgentAccount = new ConsumerAgentAccount();
        consumerAgentAccount.setFirstName("Splatt");
        consumerAgentAccount.setLastName("Testerman");
        consumerAgentAccount.setActive(true);
        consumerAgentAccount.setAccount(new Account("s@test.com", "A1"));
        consumerAgentAccount.setConsumerAccount(consumerAccount);
        consumerAccount.getConsumerAgentAccounts().add(consumerAgentAccount);
        entityManager.persist(consumerAccount);
        entityManager.persist(consumerAgentAccount);

这是来自 Glassfish 日志文件的堆栈跟踪:

[2015-03-10T05:09:08.479+0000] [glassfish 4.0] [ERROR] [] [org.hibernate.property.BasicPropertyAccessor] [tid: _ThreadID=58 _ThreadName=http-listener-1(1)] [timeMillis: 1425964148479] [levelValue: 1000] [[
  HHH000122: IllegalArgumentException in class: com.blushiftss.inserteck.entities.ConsumerAgentAccount, getter method of property: id]]
[2015-03-10T05:09:08.491+0000] [glassfish 4.0] [WARNING] [ejb.system_exception] [javax.enterprise.system.container.ejb.com.sun.ejb.containers] [tid: _ThreadID=58 _ThreadName=http-listener-1(1)] [timeMillis: 1425964148491] [levelValue: 900] [[
  EJB5184:A system exception occurred during an invocation on EJB CoreController, method: public javax.json.JsonObject com.blushiftss.inserteck.CoreController.initDatabase(javax.json.JsonObject)]]
[2015-03-10T05:09:08.491+0000] [glassfish 4.0] [WARNING] [] [javax.enterprise.system.container.ejb.com.sun.ejb.containers] [tid: _ThreadID=58 _ThreadName=http-listener-1(1)] [timeMillis: 1425964148491] [levelValue: 900] [[
javax.ejb.TransactionRolledbackLocalException: Exception thrown from bean
    at com.sun.ejb.containers.EJBContainerTransactionManager.checkExceptionClientTx(EJBContainerTransactionManager.java:662)
    at com.sun.ejb.containers.EJBContainerTransactionManager.postInvokeTx(EJBContainerTransactionManager.java:507)
    at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4475)
    at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2009)
    at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1979)
    at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:220)
    at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:88)
    at com.sun.proxy.$Proxy281.initDatabase(Unknown Source)
    at com.blushiftss.inserteck.__EJB31_Generated__CoreController__Intf____Bean__.initDatabase(Unknown Source)
    at com.blushiftss.inserteck.ws.AdminResource.initDatabase(AdminResource.java:86)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    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:4695)
    at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:630)
    at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
    at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:582)
    at org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:46)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    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:582)
    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.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    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:4667)
    at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:4655)
    at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:212)
    at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:88)
    at com.sun.proxy.$Proxy284.initDatabase(Unknown Source)
    at com.blushiftss.inserteck.ws.__EJB31_Generated__AdminResource__Intf____Bean__.initDatabase(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81)
    at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:125)
    at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$TypeOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:195)
    at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:91)
    at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:346)
    at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:341)
    at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:101)
    at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:224)
    at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
    at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
    at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317)
    at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:198)
    at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:946)
    at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:323)
    at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:372)
    at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:335)
    at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:218)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:344)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
    at org.glassfish.tyrus.servlet.TyrusServletFilter.doFilter(TyrusServletFilter.java:253)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:316)
    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:357)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188)
    at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
    at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
    at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
    at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
    at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
    at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
    at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
    at java.lang.Thread.run(Thread.java:745)
Caused by: javax.persistence.PersistenceException: org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of com.blushiftss.inserteck.entities.ConsumerAgentAccount.id
    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.blushiftss.inserteck.CoreController.initDatabase(CoreController.java:1003)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    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:4695)
    at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:630)
    at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
    at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:582)
    at org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:46)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    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:582)
    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.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    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:4667)
    at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:4655)
    at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:212)
    ... 93 more
Caused by: org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of com.blushiftss.inserteck.entities.ConsumerAgentAccount.id
    at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:192)
    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)
    ... 125 more
Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:169)
    ... 136 more
]]

我不知所措。如果我以相反的顺序保留两个新实体,它会在另一个实体上抛出异常。我认为这个问题与我在实体中嵌入了类这一事实有关,但我以前使用过这种结构没有问题。咯咯。

更新

我已将此应用程序部署到另一个完全相同的 Glassfish 服务器 4.0 u 89,并且它工作正常。不同之处在于,我需要运行它的服务器与MySQL绑定,而它现在工作的服务器是SQL Server。

我已经解决了这个问题。我使用的是Hibernate 4.3.6,但是当我降级到4.3.5时,它解决了我的问题。我不知道 4.3.6+ 中是否存在错误(因为我也尝试了 4.3.8 并且失败了),但是当您使用此版本时,当您尝试保留包含嵌入字段/对象的实体时,它会抛出上述错误。

如果你使用带有弹簧启动的devtool,它会抛出

HHH000122:非法参数类中的异常:

另一个例外是

java.lang.IllegalArgumentException: object 不是声明类的实例

我发疯了寻找解决方案。最后,我从此链接我尝试了很多东西,实体映射,配置文件不是一次而是多次。

请从您的 pom 中删除开发工具依赖项.xml.清理它并重新构建它。希望这能解决问题。

相关内容

  • 没有找到相关文章

最新更新