1

*I got the following in an entity.

@Entity("User") public class User implements java.io.Serializable { @ElementCollection(fetch=FetchType.EAGER) @CollectionTable(name="FrameworkUser_Properties") public Map<String, String> getProperties() { return properties; } public void setProperties(Map<String, String> properties) { this.properties = properties; } } 

i get the following error

Unsuccessful: create table FrameworkUser_Properties (User_id int not null, properties varchar(255) null, properties_KEY varchar(255) null, primary key (User_id, properties_KEY)) 

Anyone got any idea how i should do so is properties_KEY is not null instead? I use Hibernate Hibernate 3.6.5.Final, MSSQL

//Trind

2
  • Is the question how to define properties_KEY so it is declared in create table statement as null or is the question why table cannot be created? Commented Jul 11, 2011 at 8:03
  • I wanted it to be possible to create the table. Ken Chan soloved it for me. Commented Jul 11, 2011 at 8:17

2 Answers 2

1

It seems that you are mapping the collection of the value type using the hashmap . You have to specify the key column of the hashmap using @MapKeyColumn

For example , you can try it to see if the problem can be solved:

@ElementCollection(fetch=FetchType.EAGER) @CollectionTable(name="FrameworkUser_Properties") @MapKeyColumn public Map<String, String> getProperties() { return properties; } 
Sign up to request clarification or add additional context in comments.

Comments

1

I belive you can do something like this:

 @CollectionTable( name="FrameworkUser_Properties", joinColumns=@JoinColumn(name="OWNER_ID", nullable = false) ) 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.