-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Duplicate columns not detected by hbm2ddl
PostPosted: Wed Nov 08, 2006 11:30 am 
Regular
Regular

Joined: Thu Oct 19, 2006 12:07 pm
Posts: 75
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.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 08, 2006 6:14 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
could be added to hbmlint - put a request in jira for it

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 13, 2006 9:38 am 
Regular
Regular

Joined: Thu Oct 19, 2006 12:07 pm
Posts: 75
Did : http://opensource.atlassian.com/project ... se/HBX-815

(my first JIRA entry, so if I did something wrong, just say so ;-)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.