-->
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.  [ 2 posts ] 
Author Message
 Post subject: Annotating an OneToMany Map with a key from a third table
PostPosted: Tue Mar 16, 2010 10:53 am 
Newbie

Joined: Tue Mar 16, 2010 10:35 am
Posts: 2
I'm trying to annotate a Map<String, Child> from Parent:

Code:
@OneToMany(fetch = FetchType.LAZY)
@JoinColumn(name = "parent_id", nullable = false)
public Map<String, Child> getChildren() {}


child:

Code:
@ManyToOne
@JoinColumn(name = "parent_id", nullable = false, insertable = false, updatable = false)
public Parent getParent() {}



I have the parent.hbm.xml, from which the relevant mapping:

Code:

<map name="children" table="child">
       <key column="parent_id" foreign-key="child_parent_fk"/>
       <map-key type="string"
        formula="(select 3rd.name from thirdtable 3rd where 3rd.id = child_3rd_id)"/>
       <one-to-many class="Child"/>
    </map>


So. How do I annotate this? The aforementioned annotations do not work, they cause an exception:

Code:
org.hibernate.HibernateException: null index column for collection: Parent.children


Please note I have obfuscated the code and am simply trying to port the hbm.xml to annotations. I have no idea why the key is the name field from an associated third table/entity, but that's how it's been designed and I cannot change it.


Top
 Profile  
 
 Post subject: Re: Annotating an OneToMany Map with a key from a third table
PostPosted: Thu Mar 18, 2010 4:46 am 
Newbie

Joined: Tue Mar 16, 2010 10:35 am
Posts: 2
I don't know whether bumping is approved of, but nonetheless here is one.


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