1 Reply Latest reply on Feb 18, 2005 8:18 AM by Bill Burke

    Unknown column 'accountnam_.pk' in 'field list'

    Kari Kangas Newbie

      Hi,

      (JBOSS: 4.0.1 SP1,
      EJB3: preview3
      AOP: 1.1,
      jboss-remoting.jar is from 4.0.1 RC1 version, SP1 gave exception).


      I have 1:n bidirectional relationship and I'm not able to have it right with EJB3. In select is seems to put pk class as field into the SQL select.
      This happens when I try to cfreate new persistence objects (Account and AccountName).

      Here is select from JBoss log:

      11:33:59,173 INFO [STDOUT] Hibernate: select accountnam_.accountId, accountnam_.locale, accountnam_.name as name15_, accountnam_.explanation as explanat4_15_, accountnam_.pk as pk15_, accountnam_.id
      as id15_ from accountname accountnam_ where accountnam_.accountId=? and accountnam_.locale=?

      and the classes. One table is ACCOUNT and class is (snipped):

      @Entity @SecurityDomain("other") @Table(name = "account")
      public class Account implements Serializable, AccountLocal {
      
       private long id;
      
       private Collection<AccountName> names = new ArrayList<AccountName>();
      
       @Id(generate = GeneratorType.IDENTITY) public long getId() {
       return id;
       }
      
       public void setId(long id) {
       this.id = id;
       }
      
       @OneToMany(mappedBy="account", cascade = CascadeType.ALL)
       @JoinColumn(name = "accountId", referencedColumnName="id") public Collection<AccountName> getNames() {
       return names;
       }
      
       public void setNames(Collection<AccountName> names) {
       this.names = names;
       }
       ...
      }
      


      then the other ACCOUNTNAME and class (snipped):

      @Entity @SecurityDomain("other") @Table(name = "accountname")
      public class AccountName implements Serializable, AccountNameLocal {
      
       private AccountNamePK pk;
      
       private Account account;
      
       @EmbeddedId( {
       @AttributeOverride(name = "accountId"),
       @AttributeOverride(name = "locale") })
       public AccountNamePK getPk() {
       return pk;
       }
      
       public void setPk(AccountNamePK pk) {
       this.pk = pk;
       }
      
       @Transient public long getAccountId() {
       return getPk().getAccountId();
       }
      
       @Transient public String getLocale() {
       return this.getPk().getLocale();
       }
      
       @ManyToOne
       @JoinColumn(name = "id")
       public Account getAccount() {
       return account;
       }
      
       public void setAccount(Account account) {
       this.account = account;
       }
      
       ...
      }
      


      and finally pk class (snipped, again)

      @Embeddable public class AccountNamePK implements Serializable {
      
       private long accountId;
      
       private String locale;
      
       ...
      }
      
      


      -- kari kangas