org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of org.hibernate.bugs.Item.header

Hibernate JIRA | Frank Ellison | 3 years ago
  1. 0

    It is impossible to save with Envers Auditing enabled when the model has an embeddable that has a collection of other entities. {noformat} org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of org.hibernate.bugs.Item.header at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:192) at org.hibernate.property.BasicPropertyAccessor$BasicGetter.getForInsert(BasicPropertyAccessor.java:204) at org.hibernate.tuple.entity.AbstractEntityTuplizer.getPropertyValuesToInsert(AbstractEntityTuplizer.java:624) at org.hibernate.tuple.entity.PojoEntityTuplizer.getPropertyValuesToInsert(PojoEntityTuplizer.java:382) at org.hibernate.persister.entity.AbstractEntityPersister.getPropertyValuesToInsert(AbstractEntityPersister.java:4817) at org.hibernate.event.internal.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:267) at org.hibernate.event.internal.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:194) at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:125) at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:209) at org.hibernate.event.internal.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:55) at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:194) at org.hibernate.event.internal.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:49) at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:90) at org.hibernate.internal.SessionImpl.fireSave(SessionImpl.java:715) at org.hibernate.internal.SessionImpl.save(SessionImpl.java:707) at org.hibernate.envers.strategy.DefaultAuditStrategy.performCollectionChange(DefaultAuditStrategy.java:41) at org.hibernate.envers.internal.synchronization.work.PersistentCollectionChangeWorkUnit.perform(PersistentCollectionChangeWorkUnit.java:97) at org.hibernate.envers.internal.synchronization.AuditProcess.executeInSession(AuditProcess.java:119) at org.hibernate.envers.internal.synchronization.AuditProcess.doBeforeTransactionCompletion(AuditProcess.java:161) at org.hibernate.envers.internal.synchronization.AuditProcessManager$1.doBeforeTransactionCompletion(AuditProcessManager.java:63) at org.hibernate.engine.spi.ActionQueue$BeforeTransactionCompletionProcessQueue.beforeTransactionCompletion(ActionQueue.java:715) at org.hibernate.engine.spi.ActionQueue.beforeTransactionCompletion(ActionQueue.java:389) at org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:516) at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.beforeTransactionCommit(JdbcTransaction.java:105) at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(AbstractTransactionImpl.java:177) at org.hibernate.bugs.Hhh9105.testEmbeddableWithCollection(Hhh9105.java:74) 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:601) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) at org.junit.runners.ParentRunner.run(ParentRunner.java:309) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) 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:601) at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:169) ... 49 more {noformat} {code:title=Header.java} @Audited @Entity @Table(name = "ENVERS_HEADER") public class Header { private Long id; private String name; private EmbeddableWithCollection embeddableWithCollection; public Header() { } @Id @GeneratedValue public Long getId() { return id; } public void setId(Long id) { this.id = id; } @Column public String getName() { return name; } public void setName(String name) { this.name = name; } @Embedded public EmbeddableWithCollection getEmbeddableWithCollection() { return embeddableWithCollection; } public void setEmbeddableWithCollection(EmbeddableWithCollection embeddableWithCollection) { if (embeddableWithCollection != null) { this.embeddableWithCollection = embeddableWithCollection; } else if (this.embeddableWithCollection != null) { this.embeddableWithCollection.getItems().clear(); } } } {code} {code:title=Item.java} @Entity @Table(name = "ENVERS_ITEM") @Audited public class Item { private Long id; private String name; private Header header; private Integer position; public Item() { } @Id @GeneratedValue public Long getId() { return id; } public void setId(Long id) { this.id = id; } @Column public String getName() { return name; } public void setName(String name) { this.name = name; } @ManyToOne @JoinColumn(name = "C_HDR", insertable = false, updatable = false, nullable = false) public Header getHeader() { return header; } public void setHeader(Header header) { this.header = header; } @Column(name = "C_POSITION", insertable = false, updatable = false) public Integer getPosition() { return position; } public void setPosition(Integer position) { this.position = position; } } {code} {code:title=EmbeddableWithCollection.java} @Embeddable @Audited public class EmbeddableWithCollection { private List<Item> items; public EmbeddableWithCollection() { } @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true) @JoinColumn(name = "C_HDR", foreignKey = @ForeignKey(name = "ENVERS_ITEM_FK_ENVERS_HEADER"), nullable = false) @OrderColumn(name = "C_POSITION", nullable = false) @AuditMappedBy(mappedBy = "header", positionMappedBy = "position") public List<Item> getItems() { return items; } public void setItems(List<Item> items) { this.items = items; } } {code} Test Code project structure taken from HHH-9105 attachment. {code:title=Test.java} public class Hhh9105 { private Configuration config; private SessionFactory sessionFactory; @SuppressWarnings("deprecation") @Before public void setup() { config = new Configuration(); // add your entities here e.g.: // config.addAnnotatedClass(Customer.class); config.addAnnotatedClass(Header.class); config.addAnnotatedClass(Item.class); config.setProperty("hibernate.connection.driver_class", "org.hsqldb.jdbcDriver"); config.setProperty("hibernate.connection.url", "jdbc:hsqldb:mem:myunittests"); config.setProperty("hibernate.connection.username", "sa"); config.setProperty("hibernate.connection.password", ""); config.setProperty("hibernate.connection.pool_size", "1"); config.setProperty("hibernate.current_session_context_class", "thread"); config.setProperty("hibernate.hbm2ddl.auto", "update"); config.setProperty("hibernate.dialect", "org.hibernate.dialect.HSQLDialect"); config.setProperty("hibernate.show_sql", "true"); sessionFactory = config.buildSessionFactory(); } // perform your tests using standard junit test cases @Test public void testEmbeddableWithCollection() { Header h1 = new Header(); h1.setName("h1"); EmbeddableWithCollection ewc = new EmbeddableWithCollection(); List<Item> items = new ArrayList<Item>(); Item i1 = new Item(); i1.setHeader(h1); i1.setName("h1-item1"); i1.setPosition(0); Item i2 = new Item(); i2.setHeader(h1); i2.setName("h1-item2"); i2.setPosition(1); items.add(i1); items.add(i2); ewc.setItems(items); h1.setEmbeddableWithCollection(ewc); sessionFactory.getCurrentSession().beginTransaction(); Long headerId = (Long) sessionFactory.getCurrentSession().save(h1); sessionFactory.getCurrentSession().getTransaction().commit(); Header persistedHeader = (Header) sessionFactory.getCurrentSession() .createCriteria(Header.class) .add(Restrictions.idEq(headerId)) .uniqueResult(); Assert.assertEquals(2, persistedHeader.getEmbeddableWithCollection().getItems().size()); sessionFactory.getCurrentSession().beginTransaction(); AuditReader reader = AuditReaderFactory.get(sessionFactory.getCurrentSession()); Header auditedHeader = reader.find(Header.class, headerId, Integer.MAX_VALUE); List<Item> auditedHeader1Items = auditedHeader.getEmbeddableWithCollection().getItems(); Assert.assertEquals(2, auditedHeader1Items.size()); Assert.assertEquals("h1-item1", auditedHeader1Items.get(0).getName()); Assert.assertEquals(Long.valueOf(0), auditedHeader1Items.get(0).getPosition()); Assert.assertEquals(headerId, auditedHeader1Items.get(0).getHeader().getId()); Assert.assertEquals("h1-item2", auditedHeader1Items.get(1).getName()); Assert.assertEquals(Long.valueOf(1), auditedHeader1Items.get(1).getPosition()); Assert.assertEquals(headerId, auditedHeader1Items.get(1).getHeader().getId()); sessionFactory.getCurrentSession().getTransaction().commit(); sessionFactory.getCurrentSession().close(); } } {code} {code:title=pom.xml} <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <prerequisites> <maven>3.0.4</maven> </prerequisites> <groupId>org.hibernate.bugs</groupId> <artifactId>hhh-9105</artifactId> <version>1.0-SNAPSHOT</version> <name>Hibernate Bug Report Test Case Example</name> <properties> <slf4j.version>1.7.2</slf4j.version> </properties> <dependencies> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>${slf4j.version}</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>4.3.5.Final</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-testing</artifactId> <version>4.3.5.Final</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-envers</artifactId> <version>4.3.5.Final</version> </dependency> <dependency> <groupId>org.hsqldb</groupId> <artifactId>hsqldb</artifactId> <version>2.3.2</version> <scope>test</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.11</version> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.7</source> <target>1.7</target> </configuration> </plugin> </plugins> </build> </project> {code} {code:title=log4j.properties} # Root logger option log4j.rootLogger=INFO, stdout # Direct log messages to stdout log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.Target=System.out log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n {code}

    Hibernate JIRA | 3 years ago | Frank Ellison
    org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of org.hibernate.bugs.Item.header
  2. 0

    It is impossible to save with Envers Auditing enabled when the model has an embeddable that has a collection of other entities. {noformat} org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of org.hibernate.bugs.Item.header at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:192) at org.hibernate.property.BasicPropertyAccessor$BasicGetter.getForInsert(BasicPropertyAccessor.java:204) at org.hibernate.tuple.entity.AbstractEntityTuplizer.getPropertyValuesToInsert(AbstractEntityTuplizer.java:624) at org.hibernate.tuple.entity.PojoEntityTuplizer.getPropertyValuesToInsert(PojoEntityTuplizer.java:382) at org.hibernate.persister.entity.AbstractEntityPersister.getPropertyValuesToInsert(AbstractEntityPersister.java:4817) at org.hibernate.event.internal.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:267) at org.hibernate.event.internal.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:194) at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:125) at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:209) at org.hibernate.event.internal.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:55) at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:194) at org.hibernate.event.internal.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:49) at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:90) at org.hibernate.internal.SessionImpl.fireSave(SessionImpl.java:715) at org.hibernate.internal.SessionImpl.save(SessionImpl.java:707) at org.hibernate.envers.strategy.DefaultAuditStrategy.performCollectionChange(DefaultAuditStrategy.java:41) at org.hibernate.envers.internal.synchronization.work.PersistentCollectionChangeWorkUnit.perform(PersistentCollectionChangeWorkUnit.java:97) at org.hibernate.envers.internal.synchronization.AuditProcess.executeInSession(AuditProcess.java:119) at org.hibernate.envers.internal.synchronization.AuditProcess.doBeforeTransactionCompletion(AuditProcess.java:161) at org.hibernate.envers.internal.synchronization.AuditProcessManager$1.doBeforeTransactionCompletion(AuditProcessManager.java:63) at org.hibernate.engine.spi.ActionQueue$BeforeTransactionCompletionProcessQueue.beforeTransactionCompletion(ActionQueue.java:715) at org.hibernate.engine.spi.ActionQueue.beforeTransactionCompletion(ActionQueue.java:389) at org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:516) at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.beforeTransactionCommit(JdbcTransaction.java:105) at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(AbstractTransactionImpl.java:177) at org.hibernate.bugs.Hhh9105.testEmbeddableWithCollection(Hhh9105.java:74) 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:601) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) at org.junit.runners.ParentRunner.run(ParentRunner.java:309) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) 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:601) at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:169) ... 49 more {noformat} {code:title=Header.java} @Audited @Entity @Table(name = "ENVERS_HEADER") public class Header { private Long id; private String name; private EmbeddableWithCollection embeddableWithCollection; public Header() { } @Id @GeneratedValue public Long getId() { return id; } public void setId(Long id) { this.id = id; } @Column public String getName() { return name; } public void setName(String name) { this.name = name; } @Embedded public EmbeddableWithCollection getEmbeddableWithCollection() { return embeddableWithCollection; } public void setEmbeddableWithCollection(EmbeddableWithCollection embeddableWithCollection) { if (embeddableWithCollection != null) { this.embeddableWithCollection = embeddableWithCollection; } else if (this.embeddableWithCollection != null) { this.embeddableWithCollection.getItems().clear(); } } } {code} {code:title=Item.java} @Entity @Table(name = "ENVERS_ITEM") @Audited public class Item { private Long id; private String name; private Header header; private Integer position; public Item() { } @Id @GeneratedValue public Long getId() { return id; } public void setId(Long id) { this.id = id; } @Column public String getName() { return name; } public void setName(String name) { this.name = name; } @ManyToOne @JoinColumn(name = "C_HDR", insertable = false, updatable = false, nullable = false) public Header getHeader() { return header; } public void setHeader(Header header) { this.header = header; } @Column(name = "C_POSITION", insertable = false, updatable = false) public Integer getPosition() { return position; } public void setPosition(Integer position) { this.position = position; } } {code} {code:title=EmbeddableWithCollection.java} @Embeddable @Audited public class EmbeddableWithCollection { private List<Item> items; public EmbeddableWithCollection() { } @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true) @JoinColumn(name = "C_HDR", foreignKey = @ForeignKey(name = "ENVERS_ITEM_FK_ENVERS_HEADER"), nullable = false) @OrderColumn(name = "C_POSITION", nullable = false) @AuditMappedBy(mappedBy = "header", positionMappedBy = "position") public List<Item> getItems() { return items; } public void setItems(List<Item> items) { this.items = items; } } {code} Test Code project structure taken from HHH-9105 attachment. {code:title=Test.java} public class Hhh9105 { private Configuration config; private SessionFactory sessionFactory; @SuppressWarnings("deprecation") @Before public void setup() { config = new Configuration(); // add your entities here e.g.: // config.addAnnotatedClass(Customer.class); config.addAnnotatedClass(Header.class); config.addAnnotatedClass(Item.class); config.setProperty("hibernate.connection.driver_class", "org.hsqldb.jdbcDriver"); config.setProperty("hibernate.connection.url", "jdbc:hsqldb:mem:myunittests"); config.setProperty("hibernate.connection.username", "sa"); config.setProperty("hibernate.connection.password", ""); config.setProperty("hibernate.connection.pool_size", "1"); config.setProperty("hibernate.current_session_context_class", "thread"); config.setProperty("hibernate.hbm2ddl.auto", "update"); config.setProperty("hibernate.dialect", "org.hibernate.dialect.HSQLDialect"); config.setProperty("hibernate.show_sql", "true"); sessionFactory = config.buildSessionFactory(); } // perform your tests using standard junit test cases @Test public void testEmbeddableWithCollection() { Header h1 = new Header(); h1.setName("h1"); EmbeddableWithCollection ewc = new EmbeddableWithCollection(); List<Item> items = new ArrayList<Item>(); Item i1 = new Item(); i1.setHeader(h1); i1.setName("h1-item1"); i1.setPosition(0); Item i2 = new Item(); i2.setHeader(h1); i2.setName("h1-item2"); i2.setPosition(1); items.add(i1); items.add(i2); ewc.setItems(items); h1.setEmbeddableWithCollection(ewc); sessionFactory.getCurrentSession().beginTransaction(); Long headerId = (Long) sessionFactory.getCurrentSession().save(h1); sessionFactory.getCurrentSession().getTransaction().commit(); Header persistedHeader = (Header) sessionFactory.getCurrentSession() .createCriteria(Header.class) .add(Restrictions.idEq(headerId)) .uniqueResult(); Assert.assertEquals(2, persistedHeader.getEmbeddableWithCollection().getItems().size()); sessionFactory.getCurrentSession().beginTransaction(); AuditReader reader = AuditReaderFactory.get(sessionFactory.getCurrentSession()); Header auditedHeader = reader.find(Header.class, headerId, Integer.MAX_VALUE); List<Item> auditedHeader1Items = auditedHeader.getEmbeddableWithCollection().getItems(); Assert.assertEquals(2, auditedHeader1Items.size()); Assert.assertEquals("h1-item1", auditedHeader1Items.get(0).getName()); Assert.assertEquals(Long.valueOf(0), auditedHeader1Items.get(0).getPosition()); Assert.assertEquals(headerId, auditedHeader1Items.get(0).getHeader().getId()); Assert.assertEquals("h1-item2", auditedHeader1Items.get(1).getName()); Assert.assertEquals(Long.valueOf(1), auditedHeader1Items.get(1).getPosition()); Assert.assertEquals(headerId, auditedHeader1Items.get(1).getHeader().getId()); sessionFactory.getCurrentSession().getTransaction().commit(); sessionFactory.getCurrentSession().close(); } } {code} {code:title=pom.xml} <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <prerequisites> <maven>3.0.4</maven> </prerequisites> <groupId>org.hibernate.bugs</groupId> <artifactId>hhh-9105</artifactId> <version>1.0-SNAPSHOT</version> <name>Hibernate Bug Report Test Case Example</name> <properties> <slf4j.version>1.7.2</slf4j.version> </properties> <dependencies> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>${slf4j.version}</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>4.3.5.Final</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-testing</artifactId> <version>4.3.5.Final</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-envers</artifactId> <version>4.3.5.Final</version> </dependency> <dependency> <groupId>org.hsqldb</groupId> <artifactId>hsqldb</artifactId> <version>2.3.2</version> <scope>test</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.11</version> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.7</source> <target>1.7</target> </configuration> </plugin> </plugins> </build> </project> {code} {code:title=log4j.properties} # Root logger option log4j.rootLogger=INFO, stdout # Direct log messages to stdout log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.Target=System.out log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n {code}

    Hibernate JIRA | 3 years ago | Frank Ellison
    org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of org.hibernate.bugs.Item.header
  3. 0

    object is not an instance of declaring class -Hibernate

    Stack Overflow | 3 years ago | Flying_Machine
    org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of com.common.pojo.Certificate.id
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    IllegalArgumentException in Java Hibernate

    Stack Overflow | 2 years ago | user4359659
    org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of michal.task2.City.students
  6. 0

    java.lang.IllegalArgumentException: object is not an instance of declaring class

    GitHub | 2 years ago | BenDol
    java.lang.IllegalArgumentException: object is not an instance of declaring class

  1. Aria Pahlavan 16 times, last 2 weeks ago
  2. kjhdofjosvs 2 times, last 1 month ago
  3. tyson925 2 times, last 1 month ago
  4. kuldeep 2 times, last 2 months ago
  5. aldrinleal 1 times, last 5 months ago
6 more registered users
72 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.lang.IllegalArgumentException

    object is not an instance of declaring class

    at sun.reflect.NativeMethodAccessorImpl.invoke0()
  2. Java RT
    Method.invoke
    1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    4. java.lang.reflect.Method.invoke(Method.java:601)
    4 frames
  3. Hibernate
    SessionImpl.save
    1. org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:169)
    2. org.hibernate.property.BasicPropertyAccessor$BasicGetter.getForInsert(BasicPropertyAccessor.java:204)
    3. org.hibernate.tuple.entity.AbstractEntityTuplizer.getPropertyValuesToInsert(AbstractEntityTuplizer.java:624)
    4. org.hibernate.tuple.entity.PojoEntityTuplizer.getPropertyValuesToInsert(PojoEntityTuplizer.java:382)
    5. org.hibernate.persister.entity.AbstractEntityPersister.getPropertyValuesToInsert(AbstractEntityPersister.java:4817)
    6. org.hibernate.event.internal.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:267)
    7. org.hibernate.event.internal.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:194)
    8. org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:125)
    9. org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:209)
    10. org.hibernate.event.internal.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:55)
    11. org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:194)
    12. org.hibernate.event.internal.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:49)
    13. org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:90)
    14. org.hibernate.internal.SessionImpl.fireSave(SessionImpl.java:715)
    15. org.hibernate.internal.SessionImpl.save(SessionImpl.java:707)
    15 frames
  4. A Hibernate O/RM Module
    DefaultAuditStrategy.performCollectionChange
    1. org.hibernate.envers.strategy.DefaultAuditStrategy.performCollectionChange(DefaultAuditStrategy.java:41)
    1 frame
  5. org.hibernate.envers
    AuditProcessManager$1.doBeforeTransactionCompletion
    1. org.hibernate.envers.internal.synchronization.work.PersistentCollectionChangeWorkUnit.perform(PersistentCollectionChangeWorkUnit.java:97)
    2. org.hibernate.envers.internal.synchronization.AuditProcess.executeInSession(AuditProcess.java:119)
    3. org.hibernate.envers.internal.synchronization.AuditProcess.doBeforeTransactionCompletion(AuditProcess.java:161)
    4. org.hibernate.envers.internal.synchronization.AuditProcessManager$1.doBeforeTransactionCompletion(AuditProcessManager.java:63)
    4 frames
  6. Hibernate
    AbstractTransactionImpl.commit
    1. org.hibernate.engine.spi.ActionQueue$BeforeTransactionCompletionProcessQueue.beforeTransactionCompletion(ActionQueue.java:715)
    2. org.hibernate.engine.spi.ActionQueue.beforeTransactionCompletion(ActionQueue.java:389)
    3. org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:516)
    4. org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.beforeTransactionCommit(JdbcTransaction.java:105)
    5. org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(AbstractTransactionImpl.java:177)
    5 frames
  7. org.hibernate.bugs
    Hhh9105.testEmbeddableWithCollection
    1. org.hibernate.bugs.Hhh9105.testEmbeddableWithCollection(Hhh9105.java:74)
    1 frame
  8. Java RT
    Method.invoke
    1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    4. java.lang.reflect.Method.invoke(Method.java:601)
    4 frames
  9. JUnit
    ParentRunner.run
    1. org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    2. org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    3. org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    4. org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    5. org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    6. org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    7. org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    8. org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    9. org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    10. org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    11. org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    12. org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    13. org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    14. org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    14 frames
  10. JUnit4 Runner
    JUnit4TestReference.run
    1. org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    1 frame
  11. JUnit3 Runner
    RemoteTestRunner.main
    1. org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    2. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    3. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    4. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    5. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
    5 frames