This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Trying to map a Map<String,String> using Hibernate annotations gives the message: "Basic attributes can only be of the following types: Java primitive types, wrapper of primitive types, String, java.math.BigInteger, java.math.BigDecimal, java.util.Date, java.util.Calendar, java.sql.Date, java.sql.Time, java.sql.TimeStamp, byte[], Byte[], char[], Character[], enums, or any Serializable type." If I replace it with HashMap, it works since that implements Serializable, but I've never seen an example of it use an actual implementation of Map. I've got it annotated correctly with @CollectionOfElements and @MapKey, and even @JoinTable, but it doesn't seem to like just Map.
Is it valid declaration for attributes in your opinion?
in my opinion if spec say it should be primitive, serializable etc then warning/eror is valid as Map itself do not extend Serializable.
Except that Hibernate itself has no problem with it. If I deploy my project and run it, Hibernate will even create the table for the Map collection if I tell it to. It's just going to store a key and value pair as two columns in the database, it's not the actual map that's going to be stored. So it should probably more likely pay attention to the generics arguments since in my case what will be written to the database is the String key and String value inside the map. I suppose there's no problem with using HashMap in the declaration, but I've still seen nowhere else having to use an actual implementation of Map for just the variable declaration.
Also, looking at it, what's the difference between doing at @CollectionOfElements on a Set or a List versus a Map other than Map gets another column for the key? Both will create a new JoinTable, so they're pretty much the same except for the MapKey. Neither Set nor List implement Serializable as they're both Interfaces also, so why wouldn't they throw an error also? I'm not forced to use an ArrayList or a HashSet there to get rid of something that's not an issue in the first place where Netbeans is the only thing that is actually complaining about it.
hard to reevaluate now, but I suppose it's persistence issue, and hibernate was used as jpa provider with persistence.xml may be, now it's possible to turn off either individual jpa hints or some group of hints which may not be applicable to provider you use in your project, it's hard to handle any special providers cases and individual jpa extensions. If you are still interested and I'm wrong with my assumption, feel free to reopen the issue, it's nice to provide sample project also.