javax.persistence.PersistenceException: [PersistenceUnit: geoareas] Unable to configure EntityManagerFactory

jboss.org | 3 months ago
  1. 0

    JPA 2.0 mapping giving me an error in Eclipse/J... | JBoss Developer

    jboss.org | 3 months ago
    javax.persistence.PersistenceException: [PersistenceUnit: geoareas] Unable to configure EntityManagerFactory
  2. 0

    Hibernate: bug when mapping a reference to an alternative/natural key column of a sub table?

    Stack Overflow | 6 years ago | Kawu
    javax.persistence.PersistenceException: [PersistenceUnit: geoareas] Unable to configure EntityManagerFactory
  3. 0

    I've got what I think is a straightforward many-to-one to a composite primary key, which doesn't work as written. Here we go: User entity reads like this: @Entity @Table(name = "CTVUSERS") @IdClass(UserPK.class) @SequenceGenerator(name = "UserSeq", sequenceName = "SQ_USER") public class User { @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "UserSeq") @Column(name = "CTVUSERS_KEY") private Long userKey; @Id @Column(name = "CTVUSERS_START_DATE") private Date startDate; @Id @Column(name = "CTVUSERS_END_DATE") private Date endDate; @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, mappedBy = "user") private Set<DistrictUser> districtUsers; } The UserPK is defined like this: public class UserPK implements Serializable { private static final long serialVersionUID = -7720874756224520523L; public Long userKey; public Date startDate; public Date endDate; public UserPK() { } public UserPK(String className) { } @Override public boolean equals(Object obj) { if (!(obj instanceof UserPK)) return false; UserPK userPK = (UserPK) obj; SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy"); return userKey.equals(userPK.userKey) && formatter.format(startDate).equals(formatter.format(userPK.startDate)) && formatter.format(endDate).equals(formatter.format(userPK.endDate)); } @Override public int hashCode() { return userKey.hashCode() * startDate.hashCode() * endDate.hashCode(); } } DistrictUser entity goes as follows: @Entity @Table(name = "CLRUS2DI") @SequenceGenerator(name = "DistrictUserSeq", sequenceName = "SQ_DISTRICT_USER") public class DistrictUser { @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "DistrictUserSeq") @Column(name = "CLRUS2DI_KEY") private Long id; @ManyToOne(cascade = CascadeType.ALL) @JoinColumns( { @JoinColumn(name = "CLRUS2DI_USERS_KEY", referencedColumnName="CTVUSERS_KEY"), @JoinColumn(name = "CLRUS2DI_BEGIN_DATE", referencedColumnName="CTVUSERS_START_DATE"), @JoinColumn(name = "CLRUS2DI_END_DATE", referencedColumnName="CTVUSERS_END_DATE") }) private User user; } When I deploy the above in JBoss OR run in standalone I get: Exception in thread "main" javax.persistence.PersistenceException: org.hibernate.MappingException: Unable to find column with logical name: CTVUSERS_KEY in org.hibernate.mapping.Table(CTVUSERS) and its related supertables and secondary tables at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:173) at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:103) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:37) at com.mhe.acuity.migration.service.MigrationService.main(MigrationService.java:21) Caused by: org.hibernate.MappingException: Unable to find column with logical name: CTVUSERS_KEY in org.hibernate.mapping.Table(CTVUSERS) and its related supertables and secondary tables at org.hibernate.cfg.Ejb3JoinColumn.checkReferencedColumnsType(Ejb3JoinColumn.java:346) at org.hibernate.cfg.BinderHelper.createSyntheticPropertyReference(BinderHelper.java:80) at org.hibernate.cfg.FkSecondPass.doSecondPass(FkSecondPass.java:43) at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:233) at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:996) at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:722) at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:161) at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:567) at org.hibernate.ejb.Ejb3Configuration.createFactory(Ejb3Configuration.java:118) at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:165) ... 3 more If I remove the many-to-one from DistrictUsers everything works fine. If I remove referenceColumnName's from the many-to-one specification, the code is deployed fine but then I have the following exception in runtime: Caused by: java.sql.SQLException: ORA-00904: "USER10_"."ENDDATE": invalid identifier at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112) at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331) at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288) at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743) at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:216) at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:799) at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1039) at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:839) at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1132) at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3285) at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3329) at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeQuery(WrappedPreparedStatement.java:211) at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:139) at org.hibernate.loader.Loader.getResultSet(Loader.java:1669) at org.hibernate.loader.Loader.doQuery(Loader.java:662) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224) at org.hibernate.loader.Loader.loadEntity(Loader.java:1785) which is expected as the column names are different NOTE The mappings work as written is Kodo EJB3 preview implementation

    Hibernate JIRA | 1 decade ago | Borys Burnayev
    javax.persistence.PersistenceException: org.hibernate.MappingException: Unable to find column with logical name: CTVUSERS_KEY in org.hibernate.mapping.Table(CTVUSERS) and its related supertables and secondary tables
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    I've got what I think is a straightforward many-to-one to a composite primary key, which doesn't work as written. Here we go: User entity reads like this: @Entity @Table(name = "CTVUSERS") @IdClass(UserPK.class) @SequenceGenerator(name = "UserSeq", sequenceName = "SQ_USER") public class User { @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "UserSeq") @Column(name = "CTVUSERS_KEY") private Long userKey; @Id @Column(name = "CTVUSERS_START_DATE") private Date startDate; @Id @Column(name = "CTVUSERS_END_DATE") private Date endDate; @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, mappedBy = "user") private Set<DistrictUser> districtUsers; } The UserPK is defined like this: public class UserPK implements Serializable { private static final long serialVersionUID = -7720874756224520523L; public Long userKey; public Date startDate; public Date endDate; public UserPK() { } public UserPK(String className) { } @Override public boolean equals(Object obj) { if (!(obj instanceof UserPK)) return false; UserPK userPK = (UserPK) obj; SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy"); return userKey.equals(userPK.userKey) && formatter.format(startDate).equals(formatter.format(userPK.startDate)) && formatter.format(endDate).equals(formatter.format(userPK.endDate)); } @Override public int hashCode() { return userKey.hashCode() * startDate.hashCode() * endDate.hashCode(); } } DistrictUser entity goes as follows: @Entity @Table(name = "CLRUS2DI") @SequenceGenerator(name = "DistrictUserSeq", sequenceName = "SQ_DISTRICT_USER") public class DistrictUser { @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "DistrictUserSeq") @Column(name = "CLRUS2DI_KEY") private Long id; @ManyToOne(cascade = CascadeType.ALL) @JoinColumns( { @JoinColumn(name = "CLRUS2DI_USERS_KEY", referencedColumnName="CTVUSERS_KEY"), @JoinColumn(name = "CLRUS2DI_BEGIN_DATE", referencedColumnName="CTVUSERS_START_DATE"), @JoinColumn(name = "CLRUS2DI_END_DATE", referencedColumnName="CTVUSERS_END_DATE") }) private User user; } When I deploy the above in JBoss OR run in standalone I get: Exception in thread "main" javax.persistence.PersistenceException: org.hibernate.MappingException: Unable to find column with logical name: CTVUSERS_KEY in org.hibernate.mapping.Table(CTVUSERS) and its related supertables and secondary tables at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:173) at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:103) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:37) at com.mhe.acuity.migration.service.MigrationService.main(MigrationService.java:21) Caused by: org.hibernate.MappingException: Unable to find column with logical name: CTVUSERS_KEY in org.hibernate.mapping.Table(CTVUSERS) and its related supertables and secondary tables at org.hibernate.cfg.Ejb3JoinColumn.checkReferencedColumnsType(Ejb3JoinColumn.java:346) at org.hibernate.cfg.BinderHelper.createSyntheticPropertyReference(BinderHelper.java:80) at org.hibernate.cfg.FkSecondPass.doSecondPass(FkSecondPass.java:43) at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:233) at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:996) at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:722) at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:161) at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:567) at org.hibernate.ejb.Ejb3Configuration.createFactory(Ejb3Configuration.java:118) at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:165) ... 3 more If I remove the many-to-one from DistrictUsers everything works fine. If I remove referenceColumnName's from the many-to-one specification, the code is deployed fine but then I have the following exception in runtime: Caused by: java.sql.SQLException: ORA-00904: "USER10_"."ENDDATE": invalid identifier at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112) at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331) at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288) at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743) at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:216) at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:799) at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1039) at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:839) at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1132) at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3285) at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3329) at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeQuery(WrappedPreparedStatement.java:211) at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:139) at org.hibernate.loader.Loader.getResultSet(Loader.java:1669) at org.hibernate.loader.Loader.doQuery(Loader.java:662) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224) at org.hibernate.loader.Loader.loadEntity(Loader.java:1785) which is expected as the column names are different NOTE The mappings work as written is Kodo EJB3 preview implementation

    Hibernate JIRA | 1 decade ago | Borys Burnayev
    javax.persistence.PersistenceException: org.hibernate.MappingException: Unable to find column with logical name: CTVUSERS_KEY in org.hibernate.mapping.Table(CTVUSERS) and its related supertables and secondary tables
  6. 0

    Upgrade Spring (2.5.5 to 4.0.2) and hibernate (3.2.6 to 3.6.9) version

    Stack Overflow | 2 years ago | sanitg
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [spring/test-persistenceContext.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: Foreign key (FKEC0DF9EF331D3E16:CLIENT_ACCOUNT_SERVICE [ACCT_ID,ACCT_PTY_STA_TYP,ACCT_ROLE_TYP,ACCT_STA_TYP,PTY_ID,PTY_ROLE_TYP,PTY_STA_TYP])) must have same number of columns as the referenced primary key (ACCOUNT_PARTY [ACCT_ID,ACCT_PTY_STA_TYP,ACCT_ROLE_TYP,PTY_ID,PTY_ROLE_TYP,PTY_STA_TYP])

    1 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. org.hibernate.MappingException

      property [_tld_geoareas_bbstats_model_Zip__identifierMapper.country] not found on entity [tld.geoareas.bbstats.model.Country]

      at org.hibernate.mapping.PersistentClass.getRecursiveProperty()
    2. Hibernate
      Configuration.buildMappings
      1. org.hibernate.mapping.PersistentClass.getRecursiveProperty(PersistentClass.java:424)
      2. org.hibernate.mapping.PersistentClass.getRecursiveProperty(PersistentClass.java:375)
      3. org.hibernate.cfg.annotations.TableBinder.bindFk(TableBinder.java:414)
      4. org.hibernate.cfg.ToOneFkSecondPass.doSecondPass(ToOneFkSecondPass.java:115)
      5. org.hibernate.cfg.Configuration.processEndOfQueue(Configuration.java:1550)
      6. org.hibernate.cfg.Configuration.processFkSecondPassInOrder(Configuration.java:1473)
      7. org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1389)
      8. org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1345)
      8 frames
    3. Hibernate EJB
      HibernatePersistence.createEntityManagerFactory
      1. org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1477)
      2. org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:193)
      3. org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:1096)
      4. org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:278)
      5. org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:362)
      6. org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:56)
      6 frames
    4. JavaEE 7
      Persistence.createEntityManagerFactory
      1. javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:48)
      2. javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:32)
      2 frames
    5. tld.geoareas
      Main.main
      1. tld.geoareas.Main.main(Main.java:45)
      1 frame