org.hibernate.MappingException: Same logical column name referenced several times: Boy_countryAttitudes.boy_id Boy_id boy_id

Hibernate JIRA | Chris Wood | 1 decade ago
  1. 0

    If you use the ImprovedNamingStrategy in conjunction with Hibernate annotations, and one of your properties has an index defined via @Index, you will get the following error: Exception in thread "main" org.hibernate.MappingException: Unable to find column with logical name: email_address.email_address at org.hibernate.cfg.Mappings.getPhysicalColumnName(Mappings.java:493) at org.hibernate.cfg.IndexSecondPass.addIndexToColumn(IndexSecondPass.java:49) at org.hibernate.cfg.IndexSecondPass.doSecondPass(IndexSecondPass.java:44) at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1016) at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:244) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1172) Here's the basic example: public class EmailAddress { private int id; private String emailAddress; @Id public int getId() { return id; } public void setId(int id) { this.id = id; } @NotNull @Length(min=6, max=80) @Index(name="email_address_email_address_idx") public String getEmailAddress() { return emailAddress; } public void setEmailAddress(String emailAddress) { this.emailAddress = emailAddress; } public static void main(String[] args) { AnnotationConfiguration cfg = new AnnotationConfiguration(); cfg.configure("hibernate.cfg.xml"); //cfg.setNamingStrategy(new TestNamingStrategy()); cfg.setNamingStrategy(ImprovedNamingStrategy.INSTANCE); //cfg.setNamingStrategy(DefaultNamingStrategy.INSTANCE); cfg.addAnnotatedClass(EmailAddress.class); SessionFactory sf = cfg.buildSessionFactory(); } } Here is the config XML: <hibernate-configuration> <session-factory> <property name="hibernate.generate_statistics">true</property> <property name="dialect">org.hibernate.dialect.MySQLInnoDBDialect</property> <property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property> <property name="cglib.use_reflection_optimizer">true</property> <property name="jdbc.batch_size">10</property> <property name="use_outer_join">true</property> <property name="default_batch_fetch_size">8</property> <property name="max_fetch_depth">2</property> <property name="query.substitutions">true 1, false 0</property> </session-factory> </hibernate-configuration>

    Hibernate JIRA | 1 decade ago | Brian Lenz
    org.hibernate.MappingException: Unable to find column with logical name: email_address.email_address
  2. Speed up your debug routine!

    Automated exception search integrated into your IDE

  3. 0

    Hibernate @Embeddable class which extends another @Embeddable class, Properties not found for @OneToMany mapping

    Stack Overflow | 2 years ago
    org.hibernate.MappingException: Unable to find column with logical name: COL_1 in SomeOwnerClass

    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

      Same logical column name referenced several times: Boy_countryAttitudes.boy_id Boy_id boy_id

      at org.hibernate.cfg.Mappings.addColumnBinding()
    2. Hibernate
      Ejb3JoinColumn.addColumnBinding
      1. org.hibernate.cfg.Mappings.addColumnBinding(Mappings.java:457)
      2. org.hibernate.cfg.Ejb3JoinColumn.addColumnBinding(Ejb3JoinColumn.java:316)
      2 frames