2 Replies Latest reply on Feb 9, 2006 3:36 PM by Emmanuel Bernard

    Mixing annotations at field/setters

    Alexander Langer Newbie

      Hi!

      I don't know wether this is a bug or required by the spec. However, I couldn't figure how to file it into JIRA as an unregistered user, and JIRA wouldn't let me register as a new user, so I have to post it here.

      If you make differences in how you annotate the fields in
      I have this simple class:

      @Embeddable
      public class BlaPK
       implements Serializable {
      
       private Long id;
      
       private Integer type = TYPE_UNSPECIFIED;
      
       @Column(name="bla_pk_id")
       public Long getId() {
       return id;
       }
      
       public void setId(Long id) {
       this.id = id;
       }
      
      
       @Column(name="bla_pk_type")
       public Integer getType() {
       return type;
       }
       public void setType(Integer type) {
       this.type = type;
       }
      }
      
      
      @Entity
      public class Foo implements Serializable {
       @Id
       private Long id;
      
       @Embedded
       private BlaPK bla;
      
       // getters and setts for id/bla
      }
      


      JBoss will throw a "duplicate column id" error for class Foo. It doesn't seem to see the @Column name override in the @Embeddable class which are set on the getters.

      This used to work in JBoss 4.0.3SP1. However, in 4.0.4RC1 I have to move the annotations in the BlaPK class to the fields as well. I have the impression JBoss makes a lookup for class Foo and sees field-wise annotations, and hence doesn't recognize the annocations at the functions when it inspects the @Embedded class.

      I don't know if this required by the spec, if not, take this as a bug report (and again, sorry for not filing in JIRA).