hibernate - @MapKeyColumn(name="XXX") is not working -


i using jpa 2.1 hibernate 4.x. found @makkeycolumn not woking.

@entity public class department {     @id private int id;      @onetomany(mappedby = "department")     @mapkeycolumn(name = "cub_id")     private map<string, employee> employeesbycubicle = new hashmap<>();      public int getid() {         return id;     }      public void setid(int id) {         this.id = id;     }      public map<string, employee> getemployeesbycubicle() {         return employeesbycubicle;     }      public void setemployeesbycubicle(map<string, employee> employeesbycubicle) {         this.employeesbycubicle = employeesbycubicle;     } } 

if above code executed, can see following error

caused by: org.postgresql.util.psqlexception: error: null value in column "cub_id" violates not-null constraint   detail: failing row contains (2, xxxxxx, null, null). 

but, if omit @mapkeycolumn, it's working. can let me know why it's not working when using @mapkeycolumn

thanks response in advance :)

try defining mapkeycolumn nullable:

@mapkeycolumn(name = "cub_id", nullable = true) 

the default value nullable property 'false'.


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -