java.lang.IllegalArgumentException: expecting IdClass mapping

Stack Overflow | Achaius | 4 months ago
  1. 0

    java.lang.IllegalArgumentException: expecting IdClass mapping

    Stack Overflow | 4 months ago | Achaius
    java.lang.IllegalArgumentException: expecting IdClass mapping
  2. 0

    JPA error: expecting IdClass mapping

    Stack Overflow | 2 years ago | Heiko Wiesner
    java.lang.IllegalArgumentException: expecting IdClass mapping
  3. Speed up your debug routine!

    Automated exception search integrated into your IDE

  4. 0

    RawSqlBuilder.columnMapping() not working using DB column alias ... java.lang.IllegalArgumentException: DB Column [detail_count] not found in mapping.

    GitHub | 6 months ago | rbygrave
    java.lang.IllegalArgumentException: DB Column [detail_count] not found in mapping. Expecting one of [[order_id, count(*)]]
  5. 0

    I am trying to set up some entities with a primary foreign key relationship: - ContentRecord is the 'master' entity. - FileRecord is the 'dependent' entity. It's primary key should be called content_id and should be a foreign key to ContentRecord.id I can start up a hibernate session *without* a repository without error. However when I introduce a CrudRepository for FileRecord I get an exception on startup: "IllegalArgumentException: This class [class com.brightinteractive.contentstorage.database.FileRecord2] does not define an IdClass". This is despite the fact that {{FileRecord2}} *does* have an {{@IdClass}} annotation. My entity annotations are based on Example 1, case (a) from section 2.4.1.3 of the JPA 2.1 spec (basically I've taken that example but removed the {{name}} field from my ID class) Code snippets and stack trace: {code} @Entity @Table(uniqueConstraints = @UniqueConstraint(columnNames={"ContentIdentifier", "ContentStoreIdentifier"})) public class ContentRecord2 { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @Embedded @AttributeOverride(name="identifier", column = @Column(name="ContentStoreIdentifier")) private ContentStoreIdentifier contentStoreIdentifier; @Embedded @AttributeOverride(name="identifier", column = @Column(name="ContentIdentifier")) private ContentIdentifier contentIdentifier; {code} {code} @Entity @IdClass(FileRecordId2.class) public class FileRecord2 implements Serializable { @Id @OneToOne private ContentRecord2 content; @Column(name="Filename") private String filename; {code} {code} public class FileRecordId2 implements Serializable { private Long content; // matches name of @Id attribute and type of ContentRecord2 PK } {code} {code} import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.repository.CrudRepository; public interface FileRepository extends CrudRepository<FileRecord2, ContentRecord>, JpaSpecificationExecutor { FileRecord2 findByContent(ContentRecord contentRecord); } {code} {code} 2016/02/24 16:05:30:987 +0000 [ERROR] [main] org.springframework.test.context.TestContextManager - Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@7377781e] to prepare test instance [com.brightinteractive.contentstorage.database.FileTrackerServiceTest@b32e983] java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContext(CacheAwareContextLoaderDelegate.java:99) ~[spring-test-4.0.3.RELEASE.jar:4.0.3.RELEASE] at org.springframework.test.context.DefaultTestContext.getApplicationContext(DefaultTestContext.java:101) ~[spring-test-4.0.3.RELEASE.jar:4.0.3.RELEASE] at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:109) ~[spring-test-4.0.3.RELEASE.jar:4.0.3.RELEASE] at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75) ~[spring-test-4.0.3.RELEASE.jar:4.0.3.RELEASE] at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:319) ~[spring-test-4.0.3.RELEASE.jar:4.0.3.RELEASE] at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:212) [spring-test-4.0.3.RELEASE.jar:4.0.3.RELEASE] at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289) [spring-test-4.0.3.RELEASE.jar:4.0.3.RELEASE] at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) [junit-4.11.jar:na] at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291) [spring-test-4.0.3.RELEASE.jar:4.0.3.RELEASE] at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:232) [spring-test-4.0.3.RELEASE.jar:4.0.3.RELEASE] at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:89) [spring-test-4.0.3.RELEASE.jar:4.0.3.RELEASE] at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) [junit-4.11.jar:na] at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) [junit-4.11.jar:na] at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) [junit-4.11.jar:na] at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) [junit-4.11.jar:na] at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) [junit-4.11.jar:na] at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) [spring-test-4.0.3.RELEASE.jar:4.0.3.RELEASE] at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71) [spring-test-4.0.3.RELEASE.jar:4.0.3.RELEASE] at org.junit.runners.ParentRunner.run(ParentRunner.java:309) [junit-4.11.jar:na] at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:175) [spring-test-4.0.3.RELEASE.jar:4.0.3.RELEASE] at org.junit.runner.JUnitCore.run(JUnitCore.java:160) [junit-4.11.jar:na] at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69) [junit-rt.jar:na] at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234) [junit-rt.jar:na] at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74) [junit-rt.jar:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_72] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_72] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_72] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_72] at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) [idea_rt.jar:na] Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'fileRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: This class [class com.brightinteractive.contentstorage.database.FileRecord2] does not define an IdClass at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578) ~[spring-beans-4.2.2.RELEASE.jar:4.2.2.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) ~[spring-beans-4.2.2.RELEASE.jar:4.2.2.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.2.RELEASE.jar:4.2.2.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:305) ~[spring-beans-4.2.2.RELEASE.jar:4.2.2.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.2.RELEASE.jar:4.2.2.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:301) ~[spring-beans-4.2.2.RELEASE.jar:4.2.2.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196) ~[spring-beans-4.2.2.RELEASE.jar:4.2.2.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:753) ~[spring-beans-4.2.2.RELEASE.jar:4.2.2.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:835) ~[spring-context-4.2.2.RELEASE.jar:4.2.2.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537) ~[spring-context-4.2.2.RELEASE.jar:4.2.2.RELEASE] at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:121) ~[spring-test-4.0.3.RELEASE.jar:4.0.3.RELEASE] at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:60) ~[spring-test-4.0.3.RELEASE.jar:4.0.3.RELEASE] at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.delegateLoading(AbstractDelegatingSmartContextLoader.java:100) ~[spring-test-4.0.3.RELEASE.jar:4.0.3.RELEASE] at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.loadContext(AbstractDelegatingSmartContextLoader.java:250) ~[spring-test-4.0.3.RELEASE.jar:4.0.3.RELEASE] at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContextInternal(CacheAwareContextLoaderDelegate.java:64) ~[spring-test-4.0.3.RELEASE.jar:4.0.3.RELEASE] at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContext(CacheAwareContextLoaderDelegate.java:91) ~[spring-test-4.0.3.RELEASE.jar:4.0.3.RELEASE] ... 28 common frames omitted Caused by: java.lang.IllegalArgumentException: This class [class com.brightinteractive.contentstorage.database.FileRecord2] does not define an IdClass at org.hibernate.jpa.internal.metamodel.AbstractIdentifiableType.getIdClassAttributes(AbstractIdentifiableType.java:200) ~[hibernate-entitymanager-4.3.11.Final.jar:4.3.11.Final] at org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation$IdMetadata.<init>(JpaMetamodelEntityInformation.java:249) ~[spring-data-jpa-1.9.4.RELEASE.jar:na] at org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation.<init>(JpaMetamodelEntityInformation.java:82) ~[spring-data-jpa-1.9.4.RELEASE.jar:na] at org.springframework.data.jpa.repository.support.JpaEntityInformationSupport.getEntityInformation(JpaEntityInformationSupport.java:67) ~[spring-data-jpa-1.9.4.RELEASE.jar:na] at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getEntityInformation(JpaRepositoryFactory.java:152) ~[spring-data-jpa-1.9.4.RELEASE.jar:na] at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:99) ~[spring-data-jpa-1.9.4.RELEASE.jar:na] at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:81) ~[spring-data-jpa-1.9.4.RELEASE.jar:na] at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:185) ~[spring-data-commons-1.11.4.RELEASE.jar:na] at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.initAndReturn(RepositoryFactoryBeanSupport.java:251) ~[spring-data-commons-1.11.4.RELEASE.jar:na] at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:237) ~[spring-data-commons-1.11.4.RELEASE.jar:na] at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:92) ~[spring-data-jpa-1.9.4.RELEASE.jar:na] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637) ~[spring-beans-4.2.2.RELEASE.jar:4.2.2.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574) ~[spring-beans-4.2.2.RELEASE.jar:4.2.2.RELEASE] ... 43 common frames omitted {code}

    Spring JIRA | 9 months ago | Francis Devereux
    java.lang.IllegalStateException: Failed to load ApplicationContext

    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

      expecting IdClass mapping

      at org.hibernate.metamodel.internal.AttributeFactory$3.resolveMember()
    2. org.hibernate.metamodel
      MetamodelImpl.initialize
      1. org.hibernate.metamodel.internal.AttributeFactory$3.resolveMember(AttributeFactory.java:971)
      2. org.hibernate.metamodel.internal.AttributeFactory$5.resolveMember(AttributeFactory.java:1029)
      3. org.hibernate.metamodel.internal.AttributeFactory.determineAttributeMetadata(AttributeFactory.java:451)
      4. org.hibernate.metamodel.internal.AttributeFactory.buildIdAttribute(AttributeFactory.java:128)
      5. org.hibernate.metamodel.internal.MetadataContext.buildIdClassAttributes(MetadataContext.java:337)
      6. org.hibernate.metamodel.internal.MetadataContext.applyIdMetadata(MetadataContext.java:269)
      7. org.hibernate.metamodel.internal.MetadataContext.wrapUp(MetadataContext.java:190)
      8. org.hibernate.metamodel.internal.MetamodelImpl.initialize(MetamodelImpl.java:219)
      8 frames
    3. Hibernate
      SessionFactoryImpl.<init>
      1. org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:296)
      1 frame
    4. org.hibernate.boot
      SessionFactoryBuilderImpl.build
      1. org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:476)
      1 frame
    5. Hibernate
      Configuration.buildSessionFactory
      1. org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:707)
      2. org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:723)
      2 frames
    6. org.springframework.orm
      LocalSessionFactoryBean.afterPropertiesSet
      1. org.springframework.orm.hibernate5.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:504)
      2. org.springframework.orm.hibernate5.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:488)
      2 frames