-->
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: Limit of @MapKeyEnumerated
PostPosted: Sun May 15, 2011 7:10 am 
Newbie

Joined: Thu May 05, 2011 6:33 am
Posts: 16
Hello everybody,
I found the annotation MapKeyEnumerated limited.

Why? Becausa isn't possible to define the column name of the enumerated key.

Instead of using the defined MapKeyEnumerated annotation, I have to do, for defining enumerated key column name, with the followed annotation:

Code:
   @ManyToMany
   @MapKeyColumn(name = "SystemId")
   @JoinTable(name = "DocumentType_DocumentClass", joinColumns = {
         @JoinColumn(name = "DT_K_DOCUMENTO_AZIENDALE", referencedColumnName = "K_DOCUMENTO_AZIENDALE"),
         @JoinColumn(name = "DT_K_SOTTO_APPLICAZIONE", referencedColumnName = "K_SOTTO_APPLICAZIONE") }, inverseJoinColumns = @JoinColumn(name = "DC_K_CLASSE_DOCUMENTALE"))
   private Map<SystemId, DocumentClass> docClassMap = new HashMap<SystemId, DocumentClass>();


I think that @MapKeyEnumerated annotation should have an attribute to define in which column the key should be saved, but now, the annotation accept only the attribute value, which define the type used in mapping a map key enum type. I think an attribute like name of @MapKeyColumn is enough to achieve the result.

The problem born when I'm not free to define the column name in the db table.

Another limit is that attribute value cannot be a String. And you will asking why? Because, using maven, setting value as EnumType.String, hibernate cannot be used as provided jar, included in my project only when is necessary.

Also the example on javadoc are wrong...

Code:
   public enum ProjectStatus {COMPLETE, DELAYED, CANCELLED, IN_PROGRESS}

   public enum SalaryRate {JUNIOR, SENIOR, MANAGER, EXECUTIVE}

   @Entity public class Employee {
       @ManyToMany
       public Projects<ProjectStatus, Project> getProjects() {...}
       
       @OneToMany
       @MapKeyEnumerated([color=#FF0000]STRING[/color]) //must be EnumType.String
       public Map<SalaryRate, Employee> getEmployees() {...}
       ...
   }


Any Ideas of how improve?

_________________
Luca Preziati


Last edited by luca.preziati on Thu Aug 11, 2011 6:16 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Limit of @MapKeyEnumerated
PostPosted: Fri May 27, 2011 6:45 am 
Newbie

Joined: Thu May 05, 2011 6:33 am
Posts: 16
Nobody has to say anything?

_________________
Luca Preziati


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.