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: HIBERNATE and interface.
PostPosted: Tue Feb 12, 2008 4:15 pm 
Beginner
Beginner

Joined: Tue Feb 12, 2008 3:53 pm
Posts: 38
Hello,
I am french and i get some problems with HIBERNATE. I am mappping an object graph with HIBERNATE and somewhere I use an interface. Here is my problem :

I have a class Page which contents a HasSet of interfaces "ElementPage". It is a one-to-many relation :

Code:
class Page
{
    ......
    private Set<ElementPage> elementPages = new ....()
}

interface ElementPage {....}

I have 3 classes "Champ", "Bloc" et "Texte" that implement the "ElementPage" interface:

Code:
class Champ implements ElementPage
{
    .......
    private Page page;
}
class Bloc implements ElementPage
{
    .......
    private Page page;
}
class Texte implements ElementPage
{
    .......
    private Page page;
}

My mapping file for the class "Page" is folowing:

Code:
<hibernate-mapping ....>
      <class name="Page" table="t_page" >
             ..............
             <set name="elementPages" inverse="true">
                    <key column="PAGE_ID"  />
                    <one-to-many class="ElementPage" />
             </set>
      </class>
</hibernate-mapping>

My mapping file for the class "Champ" is folowing:


Code:
<hibernate-mapping ....>
      <class name="Champ" table="t_champ" >
             ..............
             <many-to-one column="PAGE_ID" name="page" class="Page" />
      </class>
</hibernate-mapping>

My mapping file for the class "Bloc" is folowing:


Code:
<hibernate-mapping ....>
      <class name="Bloc" table="t_bloc" >
             ..............
             <many-to-one column="PAGE_ID" name="page" class="Page" />
      </class>
</hibernate-mapping>

My mapping file for the class "Texte" is folowing:


Code:
<hibernate-mapping ....>
      <class name="Texte" table="t_texte" >
             ..............
             <many-to-one column="PAGE_ID" name="page" class="Page" />
      </class>
</hibernate-mapping>

To resume, I have a class "Page" that has an association (a set) towards several "ElementPage" which is an interface implemented by 3 other classes. I decided to map these 3 child class and not the interface itself.
The framework on which I work gives me the folowing error :
Code:
Association references unmapped class: ElementPage

Il seems that I created an association towards an interface which is not mapped and that HIBERNATE doesn't manage this. I don't know how I can implement this. If there is a genius of HIBERNATE who can help me, he or she is welcomed.
Thank you in advance for your answer.

Xavier


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.