-->
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.  [ 1 post ] 
Author Message
 Post subject: Need Help Migrating From Mapping Files To Annotation Config
PostPosted: Mon Sep 21, 2009 5:04 pm 
Newbie

Joined: Tue Jul 26, 2005 10:25 am
Posts: 12
I am trying to convert a rather tricky mapping file configuration to annotation-based configuration. My first problem is a map-based @OneToMany association:

One of my classes, Report, has the following mapping:

Code:
<class name="Report" table="T_REPORT">
   <id name="reportID" column="reportID" />

   <!-- snipped irrelevant parts -->

   <map name="equipmentStatsMap" table="T_EQUIPMENT_STATS">
      <key column="reportID" />
      <map-key-many-to-many column="EQUIPMENTTYPEID" />
      <one-to-many class="EquipmentStats" />
   </map>

</class>


Here is my annotation attempt:

Code:
public class Report implements Serializable {

   private int reportId;
   private Map<EquipmentType, EquipmentStats> equipmentStatsMap;

   @Id
   public int getReportId{
       return this.reportId;
   }

   @OneToMany
   @JoinTable(name = "T_EQUIPMENT_STATS", joinColumns= @JoinColumn(name="REPORTID"))
   @org.hibernate.annotations.MapKey(columns={@Column(name="EQUIPMENTTYPEID")})
   @MapKeyManyToMany(targetEntity = EquipmentType.class)
   public Map<EquipmentType, EquipmentStats> getEquipmentStatsMap {
      return this.equipmentStatsMap;
   }
}


However, to make this more obnoxious, here is the mapping for the key for EquipmentStats:

Code:
        <composite-id>
            <key-many-to-one name="report" class="Report" column="REPORTID"/>
            <key-many-to-one name="equipmentType" class="EquipmentType" column="EQUIPMENTTYPEID"/>
        </composite-id>


The error being thrown is actually ORA-00972, Identifier Too Long, but I'm really thinking I've screwed up the mapping of the equipmentStatsMap.

Anyhelp would be GREATLY appreciated. The docs for mapping a map aren't making much sense to me under the current circumstances.

Jason


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

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.