1 Reply Latest reply on Mar 28, 2007 11:49 AM by Mike Dougherty

    @Column Annotation doesn't seem to work...

    Eric Anderson Newbie

      It seems the @Column annotation doesn't work for some reason?

      EJB 3.0

      @NamedQuery(name = "SdsDataLoadPat.findAll", query = "select o from SdsDataLoadPat o"),
      @NamedQuery(name = "SdsDataLoadPat.findAllbyId", query = "select o from SdsDataLoadPat as o WHERE o.loadSeqNo = :loadSeqNo AND o.setId = :setId")
      @Table(name = "SDS_DATA_LOAD_PAT")
      public class SdsDataLoadPat implements Serializable {
       private String addressCity;
       @Column(name="LOAD_SEQ_NO", nullable = false)
       private Long loadSeqNo;
       @Column(name="SET_ID", nullable = false)
       private Long setId;
       private String ssn;
       private String statusCode;
       private String suffix;

      This is the sql shown from the DEBUG

      2007-03-26 08:16:05,643 DEBUG [org.hibernate.util.JDBCExceptionReporter] could not execute query [select sdsdataloa0_.loadSeqNo as loadSeqNo24_,
      sdsdataloa0_.USIIS_ID as USIIS67_24_ from SDS_DATA_LOAD_PAT sdsdataloa0_ where sdsdataloa0_.loadSeqNo=? and sdsdataloa0_.setId=?]

      The sql is being translated using the field name, not the @column name. (sdsdataloa0_.loadSeqNo=? and sdsdataloa0_.setId=?)

      Anyone have a clue why?

        • 1. Re: @Column Annotation doesn't seem to work...
          Mike Dougherty Newbie

          I can't answer the "why", but I had the same problem. I worked around it by putting the @Column annotation in the Primary Key class.

          public class Foo {
           public Long getFooId() {
           public Long getBarId() {
           public static class FooPK {
           public Long getFooId() {
           public Long getBarId() {

          Seems to have given me the result I needed. But I'm not sure how this will affect future mappings, annotations, etc.