org.hibernate.MappingException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • Hibernate Unable to find logical name
    via by Unknown author,
  • 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
    via by Borys Burnayev,
    • org.hibernate.MappingException: Unable to find column with logical name: secondary_id in org.hibernate.mapping.Table(primary_table) and its related supertables and secondary tables at org.hibernate.cfg.Ejb3JoinColumn.checkReferencedColumnsType(Ejb3JoinColumn.java:828)[hibernate-core-5.0.9.Final.jar:5.0.9.Final]

    Users with the same issue

    PilleoPilleo
    48 times, last one,
    aidoanaidoan
    2 times, last one,
    OmyaOmya
    3 times, last one,
    Unknown visitor
    Unknown visitor1 times, last one,
    Unknown visitor
    Unknown visitor1 times, last one,
    3 more bugmates