2 Replies Latest reply on Nov 30, 2007 5:46 AM by pmuir

    Deploy error on generated entities from postgres db

    cfuser123

      So far, so good w/ Seam 2.0. However, whenever I go to deploy the generated from an existing db that we're using, I get the following error;

      
      10:44:45,852 INFO [TableMetadata] table found: public.avt_region_states
      10:44:45,852 INFO [TableMetadata] columns: [id, state, code, guideid]
      10:44:45,868 WARN [ServiceController] Problem starting service persistence.units:ear=seamtest.ear,unitName=seamtest
      javax.persistence.PersistenceException: org.hibernate.HibernateException: Wrong column type: guideid, expected: varchar(4)
       at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:720)
       at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:127)
       at org.jboss.ejb3.entity.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:246)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
       :
      <snip>
       :
      10:44:51,050 ERROR [URLDeploymentScanner] Incomplete Deployment listing:
      
      --- MBeans waiting for other MBeans ---
      ObjectName: persistence.units:ear=seamtest.ear,unitName=seamtest
       State: FAILED
       Reason: javax.persistence.PersistenceException: org.hibernate.HibernateException: Wrong column type: guideid, expected: varchar(4)
       I Depend On:
       jboss.jca:service=DataSourceBinding,name=seamtestDatasource
      
      


      Oddly, when we use an older version of the Hibernate tools (using hbm.xml files vs. annotations), it works just fine. What am I missing here? TIA.

      Specifics: Postgres 8.2 DB, Seam 2.0GA, Hibernate Tools 3.2.0.b10



      The entities in question are;

      
      package com.r.model.seam;
      // Generated Nov 19, 2007 3:46:16 PM by Hibernate Tools 3.2.0.b10
      
      
      import javax.persistence.Column;
      import javax.persistence.Entity;
      import javax.persistence.FetchType;
      import javax.persistence.Id;
      import javax.persistence.JoinColumn;
      import javax.persistence.JoinColumns;
      import javax.persistence.ManyToOne;
      import javax.persistence.Table;
      import org.hibernate.validator.Length;
      import org.hibernate.validator.NotNull;
      
      /**
       * AvtRegionStates generated by hbm2java
       */
      @Entity
      @Table(name="avt_region_states"
       ,schema="public"
      )
      public class AvtRegionStates implements java.io.Serializable {
      
      
       private int id;
       private AvtRegions avtRegions;
       private String state;
      
       public AvtRegionStates() {
       }
      
       public AvtRegionStates(int id, AvtRegions avtRegions, String state) {
       this.id = id;
       this.avtRegions = avtRegions;
       this.state = state;
       }
      
       @Id
      
       @Column(name="id", unique=true, nullable=false)
       @NotNull
       public int getId() {
       return this.id;
       }
      
       public void setId(int id) {
       this.id = id;
       }
      @ManyToOne(fetch=FetchType.LAZY)
       @JoinColumns( {
       @JoinColumn(name="guideid", nullable=false),
       @JoinColumn(name="code", nullable=false) } )
       @NotNull
       public AvtRegions getAvtRegions() {
       return this.avtRegions;
       }
      
       public void setAvtRegions(AvtRegions avtRegions) {
       this.avtRegions = avtRegions;
       }
      
       @Column(name="state", nullable=false, length=0)
       @NotNull
       @Length(max=0)
       public String getState() {
       return this.state;
       }
      
       public void setState(String state) {
       this.state = state;
       }
      
      
      
      
      }
      
      
      package com.r.model.seam;
      // Generated Nov 19, 2007 3:46:16 PM by Hibernate Tools 3.2.0.b10
      
      
      import java.util.HashSet;
      import java.util.Set;
      import javax.persistence.AttributeOverride;
      import javax.persistence.AttributeOverrides;
      import javax.persistence.CascadeType;
      import javax.persistence.Column;
      import javax.persistence.EmbeddedId;
      import javax.persistence.Entity;
      import javax.persistence.FetchType;
      import javax.persistence.JoinColumn;
      import javax.persistence.ManyToOne;
      import javax.persistence.OneToMany;
      import javax.persistence.Table;
      import org.hibernate.validator.Length;
      import org.hibernate.validator.NotNull;
      
      /**
       * AvtRegions generated by hbm2java
       */
      @Entity
      @Table(name="avt_regions"
       ,schema="public"
      )
      public class AvtRegions implements java.io.Serializable {
      
      
       private AvtRegionsId id;
       private AvtGuides avtGuides;
       private String description;
       private Set<AvtRegionStates> avtRegionStateses = new HashSet<AvtRegionStates>(0);
       private Set<AvtResults> avtResultses = new HashSet<AvtResults>(0);
      
       public AvtRegions() {
       }
      
      
       public AvtRegions(AvtRegionsId id, AvtGuides avtGuides, String description) {
       this.id = id;
       this.avtGuides = avtGuides;
       this.description = description;
       }
       public AvtRegions(AvtRegionsId id, AvtGuides avtGuides, String description, Set<AvtRegionStates> avtRegionStateses, Set<AvtResults> avtResultses) {
       this.id = id;
       this.avtGuides = avtGuides;
       this.description = description;
       this.avtRegionStateses = avtRegionStateses;
       this.avtResultses = avtResultses;
       }
      
       @EmbeddedId
      
       @AttributeOverrides( {
       @AttributeOverride(name="guideid", column=@Column(name="guideid", nullable=false) ),
       @AttributeOverride(name="code", column=@Column(name="code", nullable=false, length=4) ) } )
       @NotNull
       public AvtRegionsId getId() {
       return this.id;
       }
      
       public void setId(AvtRegionsId id) {
       this.id = id;
       }
      @ManyToOne(fetch=FetchType.LAZY)
       @JoinColumn(name="guideid", nullable=false, insertable=false, updatable=false)
       @NotNull
       public AvtGuides getAvtGuides() {
       return this.avtGuides;
       }
      
       public void setAvtGuides(AvtGuides avtGuides) {
       this.avtGuides = avtGuides;
       }
      
       @Column(name="description", nullable=false, length=64)
       @NotNull
       @Length(max=64)
       public String getDescription() {
       return this.description;
       }
      
       public void setDescription(String description) {
       this.description = description;
       }
      @OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="avtRegions")
       public Set<AvtRegionStates> getAvtRegionStateses() {
       return this.avtRegionStateses;
       }
      
       public void setAvtRegionStateses(Set<AvtRegionStates> avtRegionStateses) {
       this.avtRegionStateses = avtRegionStateses;
       }
      @OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="avtRegions")
       public Set<AvtResults> getAvtResultses() {
       return this.avtResultses;
       }
      
       public void setAvtResultses(Set<AvtResults> avtResultses) {
       this.avtResultses = avtResultses;
       }
      
      
      
      
      }
      


      The DB schema




      
      
      -- Table: avt_region_states
      
      -- DROP TABLE avt_region_states;
      
      CREATE TABLE avt_region_states
      (
       state character varying NOT NULL DEFAULT 64,
       guideid integer NOT NULL,
       code character varying(4) NOT NULL,
       id serial NOT NULL,
       CONSTRAINT auto_region_states_pk PRIMARY KEY (id),
       CONSTRAINT auc_reg_states_auc_reg_fk1 FOREIGN KEY (guideid, code)
       REFERENCES avt_regions (guideid, code) MATCH SIMPLE
       ON UPDATE NO ACTION ON DELETE NO ACTION
      )
      WITHOUT OIDS;
      ALTER TABLE avt_region_states OWNER TO postgres;
      
      
      -- Index: fki_auc_reg_states_auc_reg_fk1
      
      -- DROP INDEX fki_auc_reg_states_auc_reg_fk1;
      
      CREATE INDEX fki_auc_reg_states_auc_reg_fk1
       ON avt_region_states
       USING btree
       (guideid, code);
      
      
      -- Table: avt_regions
      
      -- DROP TABLE avt_regions;
      
      CREATE TABLE avt_regions
      (
       guideid integer NOT NULL,
       code character varying(4) NOT NULL,
       description character varying(64) NOT NULL,
       CONSTRAINT auc_regions_pk PRIMARY KEY (guideid, code),
       CONSTRAINT auc_regions_auc_guides FOREIGN KEY (guideid)
       REFERENCES avt_guides (avtguideid) MATCH SIMPLE
       ON UPDATE NO ACTION ON DELETE NO ACTION
      )
      WITHOUT OIDS;
      ALTER TABLE avt_regions OWNER TO postgres;