-->
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: Association reference to interfaces
PostPosted: Tue Nov 18, 2003 5:33 am 
Newbie

Joined: Thu Nov 13, 2003 1:14 pm
Posts: 18
Location: Leinfelden-Echterdingen, Germany
Hi,

I have a 1 to N association with a class Photo at the 1-side and an interface Selection at the N-side.

The Selection-interface is implemented by the two classes RectangleSelection and PolygonSelection which are the classes I want actually to be persistent. Each of these two classes has its own table in the database. Selection does not exist in the database as it is not an instantiable class.

As the selection interface is not itself a persistent class (but the classes implementing the selection interface are), I do not create a mapping file for Selection. But as there is no mapping file for the Selection interface, hibernate can't map the association Photo->Selection (net.sf.hibernate.MappingException: Association references unmapped class: de.armax.ce.savas.entity.Selection) which is quite logical but unfortunately not what I need.

Is there any kind of "virtual" mapping to tell hibernate just that there is a class/interface (that is not really mapped to a db table) so it could map my association? Or does anyone know another workaround for this problem.

Any help would be appreciated.

Peter


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 18, 2003 6:03 am 
Expert
Expert

Joined: Tue Sep 16, 2003 4:06 pm
Posts: 318
Location: St. Petersburg, Russia
I think similar problem was discussed recently: http://forum.hibernate.org/viewtopic.ph ... base+class


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 18, 2003 7:41 am 
Newbie

Joined: Thu Nov 13, 2003 1:14 pm
Posts: 18
Location: Leinfelden-Echterdingen, Germany
You're right. The problem is similar (an I admit, I did not read the posts) but not the same ;-).

I read through the posts but I did not find the answer to my question. Obviously one must not integrate mappings for abstract classes or interfaces and it will work for hibernate queries.

But my problem is that hibernate fails to initialize because onother class contains a reference to the interface, that has no mapping file. See mapping for Photo below. Selection is an interface and has no mapping defined (the classes implementing Selection have defined mappings).

Code:
  <class
    name="de.armax.ce.savas.entity.Photo"
    table="Photo">
    ...
    <set lazy="true" cascade="none" access="field"
      name="bluredSelections"
    >
      <key column="photoOID"/>
      <one-to-many
        class="de.armax.ce.savas.entity.Selection"/>
    </set>
  </class>


I get an net.sf.hibernate.MappingException: Association references unmapped class: de.armax.ce.savas.entity.Selection

So my question is: how can I make a reference to such an interface?

Thanks,

Peter


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 18, 2003 7:49 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
You have two choices. Either:

(1) map the interface as a <class>, and its implementors as subclasses
(2) use a <many-to-any> mapping


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.