[hibernate-issues] [Hibernate-JIRA] Created: (HBX-815) [hbmlint] Detect repeated columns

David Balažic (JIRA) noreply at atlassian.com
Mon Nov 13 08:39:04 EST 2006


[hbmlint] Detect repeated columns
---------------------------------

         Key: HBX-815
         URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-815
     Project: Hibernate Tools
        Type: New Feature

    Versions: 3.2beta8    
 Environment: hibernate v3.2, MySQL 5.1.12-beta-community-nt
    Reporter: David Balažic


(verbatim from the forum , http://forum.hibernate.org/viewtopic.php?t=967007 )


Hi!

I use hbm2ddl (from Hibernate Tools v3.2 beta 8) to create the DB schema and noticed, that duplicate column names are not detected.

Example:


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.manning.hq.stein.data">
   <class name="TelefonskiImenik">
      <id name="id" column="imid">
         <generator class="native" />
      </id>

      <property name="izdajatelj" column="col"/>
      <property name="verzija" column="col"/>

   </class>
</hibernate-mapping>


The same thing happens if one column name is implicit :


      <property name="izdajatelj" column="verzija"/>
      <property name="verzija"/>



If I try to use this mapping with an application, hibernate (v3.2) fails (in both cases) in buildSessionFactory() :

Exception in thread "main" org.hibernate.MappingException: Repeated column in mapping for entity: com.manning.hq.stein.data.TelefonskiImenik column: verzija (should be mapped with insert="false" update="false")
at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:605)
at org.hibernate.mapping.PersistentClass.checkPropertyColumnDuplication(PersistentClass.java:627)
at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:645)
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:420)
at org.hibernate.mapping.RootClass.validate(RootClass.java:192)
at org.hibernate.cfg.Configuration.validate(Configuration.java:1026)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1211)
at com.manning.hq.stein.Main2.persist_all(Main2.java:284)
at com.manning.hq.stein.Main2.main(Main2.java:45)


While this is not a severe bug, it would be nice to detect it as early as possible.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira





More information about the hibernate-issues mailing list