Hibernate Annotation problem

Column annotation are ignored, if you mix the targets where you place them.

I assigned the @Id annotation to the field and the other annotations to a method. If the @Id annotation is assigned to a field, further method annotations are ignored and vice versa.

Below you can see an example class explaining the problem. The @Column annotation of getNameMethod is ignored.

{% highlight java %}
package de.laliluna.annotation;

import java.io.Serializable;
public class SimpleBean implements Serializable {

public static void main(String[] args) { new SchemaExport(new AnnotationConfiguration().configure()).create(true, false); } @Id private Integer id; private String nameMethod; @Column(name = “name_field”) private String nameField; public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getNameField() { return nameField; } public void setNameField(String nameField) { this.nameField = nameField; } @Column(name = “name_method”) public String getNameMethod() { return nameMethod; } public void setNameMethod(String nameMethod) { this.nameMethod = nameMethod; }

{% endhighlight %}