-->
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.  [ 4 posts ] 
Author Message
 Post subject: Two set collections get created instead of one
PostPosted: Wed Jun 28, 2006 1:49 pm 
Newbie

Joined: Fri Jun 09, 2006 7:22 am
Posts: 8
I have the following in my reveng.xml file. I have one-to-many association between two tables. I declare what I want as a property name for the collection on the many side. the <hbm2hbmxml> ant task instead creates TWO collections and I can't get it to NOT create the one it automatically inserts into the generated mapping file.

Hibernate version:
Hibernate Tools 3.1.0.beta5

Mapping documents:
portion of my revng.xml file:
Code:
<!-- ProjectedInterestRate -->
   <table  name="proj_int" class="ProjectedInterestRate">
      <primary-key>
         <key-column name="profile_name" property="profileName"/>
         <key-column name="idx_code" property="indexCode"/>
         <key-column name="month" property="month"/>
      </primary-key>      
       <foreign-key constraint-name="ProjIdxToProfile"  foreign-table="run_profile"    >
         <column-ref local-column="profile_name" foreign-column="profile_name" />
         <set property="projectedInterestRates" exclude="false" />
      </foreign-key>
   </table>
      
      <!-- RunProfile -->
   <table name="run_profile" class="RunProfile">
      <primary-key>
         <key-column name="profile_name" property="profileName"/>
      </primary-key>
   </table>


Code between sessionFactory.openSession() and session.close():
NA

Full stack trace of any exception that occurs:
NA

Name and version of the database you are using:
Sybase ASE v 12

The generated mapping files:
In RunProfile.hbm.xml
Code:
<set name="projectedInterestRates" inverse="true">
            <key>
                <column name="profile_name" length="50" not-null="true" />
            </key>
            <one-to-many class="ProjectedInterestRate" />
        </set>
        <set name="projIntsForProfileName" inverse="true">
            <key>
                <column name="profile_name" length="50" not-null="true" />
            </key>
            <one-to-many class="ProjectedInterestRate" />
        </set>


notice the <set name="projIntsForProfileName" that was generated by itself. I can't seem to get rid of it. I can't manually edit it becuase the mapping file generation thorugh ant needs to be automatic. I could ofcourse add an ant task to go and edit the property value but I am still interested in why this is happening.

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 30, 2006 5:11 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
your constraint-name does not match the one in the db, thus you are actually defining an additional constraint.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 30, 2006 10:03 am 
Newbie

Joined: Fri Jun 09, 2006 7:22 am
Posts: 8
When i do use the constraint name (fsm_proj_i_443148624 ) it throws an exception:

Code:
An exception occurred while running exporter #2:hbm2hbmxml (Generates a set of hbm.xml files)
[hibernatetool] To get the full stack trace run ant with -verbose
[hibernatetool] org.hibernate.MappingException: Foreign key fsm_proj_i_443148624 already defined in the database!
      [ant] Exiting /home/***/***/ant/hibernate.xml.

BUILD FAILED
/home/***/***/build.xml:80: Following error occured while executing this line
/home/***/***/ant/hibernate.xml:59: org.hibernate.MappingException: Foreign key fsm_proj_i_443148624 already defined in the database!
        at org.apache.tools.ant.ProjectHelper.addLocationToBuildException(ProjectHelper.java:537)
        at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:385)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:269)
        at org.apache.tools.ant.Task.perform(Task.java:364)
        at org.apache.tools.ant.Target.execute(Target.java:301)
        at org.apache.tools.ant.Target.performTasks(Target.java:328)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1215)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1063)
        at org.apache.tools.ant.Main.runBuild(Main.java:632)
        at org.apache.tools.ant.Main.startAnt(Main.java:183)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:197)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:56)
Caused by: /home/***/***/ant/hibernate.xml:59: org.hibernate.MappingException: Foreign key fsm_proj_i_443148624 already defined in the database!
        at org.hibernate.tool.ant.HibernateToolTask.reportException(HibernateToolTask.java:194)
        at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:163)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:269)
        at org.apache.tools.ant.Task.perform(Task.java:364)
        at org.apache.tools.ant.Target.execute(Target.java:301)
        at org.apache.tools.ant.Target.performTasks(Target.java:328)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1215)
        at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:383)
        ... 10 more
Caused by: org.hibernate.MappingException: Foreign key fsm_proj_i_443148624 already defined in the database!
        at org.hibernate.cfg.reveng.JDBCReader.processForeignKeys(JDBCReader.java:215)
        at org.hibernate.cfg.reveng.JDBCReader.readDatabaseSchema(JDBCReader.java:94)
        at org.hibernate.cfg.reveng.JDBCReader.readDatabaseSchema(JDBCReader.java:781)
        at org.hibernate.cfg.JDBCBinder.readDatabaseSchema(JDBCBinder.java:115)
        at org.hibernate.cfg.JDBCBinder.readFromDatabase(JDBCBinder.java:87)
        at org.hibernate.cfg.JDBCMetaDataConfiguration.readFromJDBC(JDBCMetaDataConfiguration.java:40)
        at org.hibernate.tool.ant.JDBCConfigurationTask.doConfiguration(JDBCConfigurationTask.java:76)
        at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:55)
        at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:226)
        at org.hibernate.tool.ant.HibernateToolTask.getProperties(HibernateToolTask.java:242)
        at org.hibernate.tool.ant.ExporterTask.configureExporter(ExporterTask.java:94)
        at org.hibernate.tool.ant.ExporterTask.execute(ExporterTask.java:39)
        at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:160)
        ... 16 more
--- Nested Exception ---
/home/***/***/ant/hibernate.xml:59: org.hibernate.MappingException: Foreign key fsm_proj_i_443148624 already defined in the database!
        at org.hibernate.tool.ant.HibernateToolTask.reportException(HibernateToolTask.java:194)
        at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:163)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:269)
        at org.apache.tools.ant.Task.perform(Task.java:364)
        at org.apache.tools.ant.Target.execute(Target.java:301)
        at org.apache.tools.ant.Target.performTasks(Target.java:328)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1215)
        at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:383)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:269)
        at org.apache.tools.ant.Task.perform(Task.java:364)
        at org.apache.tools.ant.Target.execute(Target.java:301)
        at org.apache.tools.ant.Target.performTasks(Target.java:328)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1215)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1063)
        at org.apache.tools.ant.Main.runBuild(Main.java:632)
        at org.apache.tools.ant.Main.startAnt(Main.java:183)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:197)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:56)
Caused by: org.hibernate.MappingException: Foreign key fsm_proj_i_443148624 already defined in the database!
        at org.hibernate.cfg.reveng.JDBCReader.processForeignKeys(JDBCReader.java:215)
        at org.hibernate.cfg.reveng.JDBCReader.readDatabaseSchema(JDBCReader.java:94)
        at org.hibernate.cfg.reveng.JDBCReader.readDatabaseSchema(JDBCReader.java:781)
        at org.hibernate.cfg.JDBCBinder.readDatabaseSchema(JDBCBinder.java:115)
        at org.hibernate.cfg.JDBCBinder.readFromDatabase(JDBCBinder.java:87)
        at org.hibernate.cfg.JDBCMetaDataConfiguration.readFromJDBC(JDBCMetaDataConfiguration.java:40)
        at org.hibernate.tool.ant.JDBCConfigurationTask.doConfiguration(JDBCConfigurationTask.java:76)
        at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:55)
        at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:226)
        at org.hibernate.tool.ant.HibernateToolTask.getProperties(HibernateToolTask.java:242)
        at org.hibernate.tool.ant.ExporterTask.configureExporter(ExporterTask.java:94)
        at org.hibernate.tool.ant.ExporterTask.execute(ExporterTask.java:39)
        at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:160)
        ... 16 more
--- Nested Exception ---
org.hibernate.MappingException: Foreign key fsm_proj_i_443148624 already defined in the database!
        at org.hibernate.cfg.reveng.JDBCReader.processForeignKeys(JDBCReader.java:215)
        at org.hibernate.cfg.reveng.JDBCReader.readDatabaseSchema(JDBCReader.java:94)
        at org.hibernate.cfg.reveng.JDBCReader.readDatabaseSchema(JDBCReader.java:781)
        at org.hibernate.cfg.JDBCBinder.readDatabaseSchema(JDBCBinder.java:115)
        at org.hibernate.cfg.JDBCBinder.readFromDatabase(JDBCBinder.java:87)
        at org.hibernate.cfg.JDBCMetaDataConfiguration.readFromJDBC(JDBCMetaDataConfiguration.java:40)
        at org.hibernate.tool.ant.JDBCConfigurationTask.doConfiguration(JDBCConfigurationTask.java:76)
        at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:55)
        at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:226)
        at org.hibernate.tool.ant.HibernateToolTask.getProperties(HibernateToolTask.java:242)
        at org.hibernate.tool.ant.ExporterTask.configureExporter(ExporterTask.java:94)
        at org.hibernate.tool.ant.ExporterTask.execute(ExporterTask.java:39)
        at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:160)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:269)
        at org.apache.tools.ant.Task.perform(Task.java:364)
        at org.apache.tools.ant.Target.execute(Target.java:301)
        at org.apache.tools.ant.Target.performTasks(Target.java:328)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1215)
        at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:383)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:269)
        at org.apache.tools.ant.Task.perform(Task.java:364)
        at org.apache.tools.ant.Target.execute(Target.java:301)
        at org.apache.tools.ant.Target.performTasks(Target.java:328)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1215)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1063)
        at org.apache.tools.ant.Main.runBuild(Main.java:632)
        at org.apache.tools.ant.Main.startAnt(Main.java:183)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:197)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:56)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 30, 2006 10:39 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
can you verify this against SVN or latest nightly build ?

if it still prevails please create an jira issue with SQL DDL and reveng.xml and build.xml file that will fail against it.

_________________
Max
Don't forget to rate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.