Hibernate Null value for @CollectionOfElements

I map the attribute set to my entity using @CollectionOfElements. The goal here is to provide a list of metadata that can be used in a request to pull certain records.

I calculated the mapping and how to fulfill the queries that I want. The problem is that sleep mode will not save zero values!

@CollectionOfElements() @JoinTable(name = "plan_attribute", joinColumns = @JoinColumn(name = "plan_id")) @MapKey(columns = @Column(name = "attribute_name", nullable = false, length = 255)) @Column(name = "attribute_value", nullable = true, length = 255) public Map getAttributes() { return attributes; } public void setAttributes(Map attributes) { this.attributes = attributes; } public void addAttribute(String name, String value) { this.attributes.put(name, value); } 

Eg. object.addAttribute ("someName", null); will not be saved

Does anyone have thoughts on how to do this without embedding the key / value pair object for the sole purpose of storing these values?

Hi,

+7
collections hibernate
source share
1 answer

Quote from OP comments:

Hibernate 3.3.2.GA, so yes - it looks like this error is applied. I could work around the problem of setting null values ​​as the character '*' which actually works quite well and better than null for my use cases.

This answer should get it on the list of unanswered questions until a private ballot is held.

+2
source share

All Articles