In a One To One mapping, I wrote the following lines of code.
@GenericGenerator(name = "generator", strategy = "foreign", parameters = @Parameter(name="property", value= "post"))
@Id
@GeneratedValue(generator = "generator")
public int getContent_id() {
return content_id;
}
What is the significance of @Parameter(name=”property”, value= “post”). If I don’t write that line I’m getting an error
Invocation of init method failed; nested exception is org.hibernate.MappingException: Could not instantiate id generator [entity-name=in.codejava.personal.model.Content]
EDIT
When I changed the value = “post” to anything else like value=”post123″ etc it works. But it doesn’t work when I completely remove that. Partial Code http://pastebin.com/CjEpqtXV
It allows telling the generator from which property the ID must be extracted (in this case: “post”). An entity could have several OnetoOne associations. You need to tell it which one of them contains the ID of your entity.
Note that this generator can be replaced by a standard JPA annotation on the OneToOne association containing the ID: @MapsId. The Hibernate documentation recommends its usage rather than the foreign generator.