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:
Code:
<?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 :
Code:
<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.