-->
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: Mapping an enumeration that implements an interface
PostPosted: Sat Dec 15, 2007 9:03 am 
Newbie

Joined: Sat Dec 15, 2007 8:25 am
Posts: 1
Hello,

I have the following situation: I need to have a HashMap like this:
Code:
HashMap<ExtendedSeniorityType, SeniorityTotal>.

The contents of this HashMap do NOT need to be saved in the database, so this association is not mapped in the mapping file of the class that this HashMap is declared in.

ExtendedSeniorityType is an interface:

Code:
package data;

import enumerations.Profession;

public interface ExtendedSeniorityType {
   public String getDescription();
   
   public Profession getProfession();
}


There are 2 objects that implement this interface, but one of them in an enumeration:

Code:
package enumerations;

import data.ExtendedSeniorityType;

public enum SeniorityType implements ExtendedSeniorityType {
   Administrative {
      public String getDescription() {..}
      public Profession getProfession() {...}
   },
   VE {
      public String getDescription() {..}
      public Profession getProfession() {...}
   },
   VO {
      public String getDescription() {..}
      public Profession getProfession() {...}
   };
   
   public abstract String getDescription();
   public abstract Profession getProfession();
}

(I left out the code for getDescription() and getProfession())

The other is a normal class that can be persisted:
Code:
public class Subject extends AbstractGenericEntity<Long, Subject> implements ExtendedSeniorityType {
   public String getDescription() {..}
   public Profession getProfession() {...}

   ...
}


How can I map this structure in Hibernate? Normally, when using an interface, I would do it like described in http://www.hibernate.org/hib_docs/reference/en/html/inheritance.html
but it can't be done like that when one of the classes that implements the interface is an enumeration (because there's no way to declare a (sub)class that is an enumeration)...


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.