3 Replies Latest reply on Feb 28, 2012 7:09 AM by jskovjyskebankdk

    JPA validation fails

    jskovjyskebankdk

      Hi,

       

      I just closed an issue I created against Dali: https://bugs.eclipse.org/bugs/show_bug.cgi?id=372478 (I included the text below)

       

      It appears that the JPA validation error (Column "attributes" cannot be found on table...) we get is due to a problem in JBoss Tools, Hibernate.

       

      I wonder if we need to "do something" to make the validation pass, or it is indeed a bug. We can disable the validation as a workaround, but would like it working, obviously.

       

      The reason I ask, is that it seems such an obvious problem, and I can't find anything currently open (or closed) in Jira to explain it.

      We see it in more than one class. Maybe it's just a problem with the coding style here

       

      On the other hand, switching the JPA platform to Generic fixes the problem, so maybe not.

       

      I just tried the JBoss Tools nightly build from yesterday (on 3.7sr2) and could still reproduce.

       

      Is it something I should file a Jira issue for?

       

      Thx,

      Jesper

       

       

      ------ from the closed Eclipse issue -------

      Build Identifier: Build id: 20120216-1857

       

      We see a false error from the validation rule: Database/Column/Column cannot be

      resolved.

       

      The class with the validation error is this:

       

      @Entity

      @Table(name = "PasswordResourceAuditLog", uniqueConstraints =

      @UniqueConstraint(columnNames = { "timestamp" }))

      public class PasswordResourceAuditLogEntry extends UUIDEntity implements

      LogEntry, Serializable {

          @Column(length = 50)

          private String username;

          private String dataSourceName;

          @Temporal(TemporalType.TIMESTAMP)

          private Date timestamp;

          @OneToOne(fetch=FetchType.EAGER)

          private PasswordAttributes attributes;

      ...

       

      The field attributes gets a validation error:

       

      Column "attributes" cannot be resolved on table "PASSWORDRESOURCEAUDITLOG"

       

       

      The class PasswordAttributes looks like this:

       

      @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)

      @Entity

      abstract public class PasswordAttributes extends UUIDEntity {

          public abstract PasswordAttributes copy();

          public abstract PasswordType getType();

          public void setType(PasswordType type){

              //dummy method due to EL

          }   

      }

       

      and in turn:

       

      @MappedSuperclass

      public class UUIDEntity implements Serializable {

          @Id @GeneratedValue(generator="system-uuid")

          @GenericGenerator(name="system-uuid",strategy = "uuid")   

          @Column(length=32)

          @Size(max=32, min=32)

          protected String id;

          @SuppressWarnings("unused")

          @Version

          private Long version;

       

          public String getId() {

              return id;

          }

      }

       

       

      Looking in the database (tables created by Hibernate, no custom configuration

      as far as I know), the column is actually called ATTRIBUTES_ID.

       

      We would expect the validator to look for this, not a column named ATTRIBUTES.