-->
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.  [ 5 posts ] 
Author Message
 Post subject: Can I map to different objects with same name?
PostPosted: Fri Mar 19, 2004 11:13 pm 
Newbie

Joined: Fri Mar 19, 2004 11:04 pm
Posts: 4
Location: WI
Hello - I'm a first time user of Hibernate and have been pleased so far with the product. I think the answer is "no" to this question but figured that someone would know for sure...

I am putting together a library application. I've got videos, books, music. All of which have an attribute of media. Media resides in different packages for the individual domains - books include softcover/hardcover; music includes CD, cassette, etc; video includes DVD, VHS, etc.

I've defined each as a subclass and get the following exception:
Code:
20:38:34,459 ERROR Configuration:252 - Could not compile the mapping document
net.sf.hibernate.MappingException: duplicate import: Media
   at net.sf.hibernate.cfg.Mappings.addImport(Mappings.java:85)
   at net.sf.hibernate.cfg.Binder.bindClass(Binder.java:126)


I expect that I need to name the classes differently. Is this correct or is there a trick about it?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 20, 2004 12:05 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Show us the mapping documents, I don't quite follow what you are doing.


Top
 Profile  
 
 Post subject: Sorry - Here's the mapping document...
PostPosted: Sat Mar 20, 2004 10:24 am 
Newbie

Joined: Fri Mar 19, 2004 11:04 pm
Posts: 4
Location: WI
At a high-level view, I want a lookup table with differing lookup values. I figured that a simple class could be used - each specific value could then be exnteded from the simple class.

You'll note that Genre and Media is used by more than one domain. Is this possible? I can have specific names (ie, BookMedia, VideoMedia, MusicMedia) - but I'd prefer not to.

An alternate question could be: What is the "Hibernate" way to have lookup values and share them in one table?

Here's the mapping document:

Code:
<hibernate-mapping>
    <class name="com.webcodepro.library.domain.Flyweight"
          table="Flyweights">
        <id name="id">
            <generator class="hilo">
               <param name="table">ObjectId</param>
               <param name="column">next_value</param>
               <param name="max_lo">10</param>
            </generator>
        </id>
        <discriminator column="class_name" type="string"/>
        <property name="value"/>
        <subclass name="com.webcodepro.library.domain.video.Genre"
                discriminator-value="video.Genre"/>
        <subclass name="com.webcodepro.library.domain.video.Media"
                discriminator-value="video.Media"/>
        <subclass name="com.webcodepro.library.domain.video.Rating"
                discriminator-value="video.Rating"/>
<!--
        <subclass name="com.webcodepro.library.domain.music.Artist"
                discriminator-value="music.Artist"/>
        <subclass name="com.webcodepro.library.domain.music.Media"
                discriminator-value="music.Media"/>
        <subclass name="com.webcodepro.library.domain.book.Collection"
                discriminator-value="book.Collection"/>
        <subclass name="com.webcodepro.library.domain.book.Genre"
                discriminator-value="book.Genre"/>
        <subclass name="com.webcodepro.library.domain.book.Media"
                discriminator-value="book.Media"/>
-->
    </class>

</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 20, 2004 10:42 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
i had many troubles with xml comment, maybe it's only this, change
Code:
<!--
        <subclass name="com.webcodepro.library.domain.music.Artist"
                discriminator-value="music.Artist"/>
        <subclass name="com.webcodepro.library.domain.music.Media"
                discriminator-value="music.Media"/>
        <subclass name="com.webcodepro.library.domain.book.Collection"
                discriminator-value="book.Collection"/>
        <subclass name="com.webcodepro.library.domain.book.Genre"
                discriminator-value="book.Genre"/>
        <subclass name="com.webcodepro.library.domain.book.Media"
                discriminator-value="book.Media"/>
-->

to
Code:
        <!--subclass name="com.webcodepro.library.domain.music.Artist"
                discriminator-value="music.Artist"/-->
        <!--subclass name="com.webcodepro.library.domain.music.Media"
                discriminator-value="music.Media"/-->
        <!--subclass name="com.webcodepro.library.domain.book.Collection"
                discriminator-value="book.Collection"/-->
        <!--subclass name="com.webcodepro.library.domain.book.Genre"
                discriminator-value="book.Genre"/-->
        <!--subclass name="com.webcodepro.library.domain.book.Media"
                discriminator-value="book.Media"/-->



Top
 Profile  
 
 Post subject: Comments
PostPosted: Sat Mar 20, 2004 11:34 am 
Newbie

Joined: Fri Mar 19, 2004 11:04 pm
Posts: 4
Location: WI
The block is commented out because of the error listed in the first message. I'll uncomment it when I know if I can fix it or if I need to rename my classes... (c:


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