[ http://jira.jboss.com/jira/browse/EJBTHREE-76?page=history ] Bill Burke closed EJBTHREE-76: ------------------------------
Resolution: Done Stupid bug where EntityToHibernateXml was looking at EmbeddedId property twice > composite pk class in SQL select as a column name > ------------------------------------------------- > > Key: EJBTHREE-76 > URL: http://jira.jboss.com/jira/browse/EJBTHREE-76 > Project: EJB 3.0 > Type: Bug > Versions: Preview 4 > Reporter: Kari Kangas > Assignee: Bill Burke > Fix For: Preview 4 > > > I have two classes with 1:n relationship, Account and AccountName, > and AccountNamePK composite pk class. > I tried to create persistence object Account with one AccountName. > Account has ID as a pk field. > AccountNamePK is composed from id and locale in where id refers to Account id. > During creation JBoss executes select to AccountName table and > puts 'pk' as field into the 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_, <========= PK field as a column name !!! > accountnam_.id > as id15_ from accountname accountnam_ where accountnam_.accountId=? and > accountnam_.locale=? > ----------------------- > Account class: > @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; > } > ... > } > ----------------------- > AccountName class: > @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; > } > ... > } > ------------------ > AccountNamePK class: > @Embeddable public class AccountNamePK implements Serializable { > private long accountId; > private String locale; > ... > } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa - If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ JBoss-Development mailing list JBoss-Development@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jboss-development