[ https://issues.apache.org/jira/browse/OPENJPA-201?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
George Hongell updated OPENJPA-201: ----------------------------------- Attachment: Winery.java Wine.java I am attaching the Wine and Winery files. There is a bilateral 1-M relationship between Winery and Wine. Winery maps to 2 tables. The foreign key is in the Wine table, I thought the table referred to in @JoinColumn was the referenced table for the relationship but now I think I was specifying the wrong table and it should be the primary table owning the relationship. However when I try using cxWine as the table, @JoinColumn(name="NEW_WINERY_WINERYID", table="cxWINE") I get both the default and the new foreign key columns. What am I doing wrong now? 3345 cxwineTour TRACE [main] openjpa.jdbc.SQL - <t 1094861122, conn 781725336> executing stmnt 1330401100 CREATE TABLE CxWine (wineid INTEGER NOT NULL, cost SMALLINT, description VARCHAR(254), minimumHoldYears INTEGER, rating SMALLINT, stockCount INTEGER, type VARCHAR(20), version INTEGER, alcoholPercent DOUBLE, ava VARCHAR(40), bottler VARCHAR(40), brandName VARCHAR(40), labelWineClass VARCHAR(20), labelWineColor VARCHAR(20), estateBottled SMALLINT, hasSulfites SMALLINT, labelid INTEGER, mlContents INTEGER, qualityDesignation VARCHAR(40), vineyardName VARCHAR(40), vintage TIMESTAMP, wineName VARCHAR(40), winesProduced_wineid INTEGER, NEW_WINERY_WINERYID INTEGER, PRIMARY KEY (wineid)) when I don't specify the table, @JoinColumn(name="NEW_WINERY_WINERYID") I get 3325 cxwineTour TRACE [main] openjpa.jdbc.SQL - <t 1094861122, conn 1569086854> executing stmnt 2042263994 CREATE TABLE CxWine (wineid INTEGER NOT NULL, cost SMALLINT, description VARCHAR(254), minimumHoldYears INTEGER, rating SMALLINT, stockCount INTEGER, type VARCHAR(20), version INTEGER, alcoholPercent DOUBLE, ava VARCHAR(40), bottler VARCHAR(40), brandName VARCHAR(40), labelWineClass VARCHAR(20), labelWineColor VARCHAR(20), estateBottled SMALLINT, hasSulfites SMALLINT, labelid INTEGER, mlContents INTEGER, qualityDesignation VARCHAR(40), vineyardName VARCHAR(40), vintage TIMESTAMP, wineName VARCHAR(40), NEW_WINERY_WINERYID INTEGER, PRIMARY KEY (wineid)) in Winery @Entity @Table(name="CxWinery") public class Winery { ... @OneToMany(mappedBy="winery") @LRS private Collection<Wine> winesProduced; in Wine @Entity @Table(name="CxWine") public class Wine { ... @ManyToOne() @Unique // gfh fails @JoinColumn(name="NEW_WINERY_WINERYID", referencedColumnName="WINERYID", table="cxWinery") // gfh fails @JoinColumn(name="NEW_WINERY_WINERYID", table="cxWINERY") // @JoinColumn(name="NEW_WINERY_WINERYID", referencedColumnName="wineryid") // @JoinColumn(name="NEW_WINERY_WINERYID") private Winery winery; > Mapping Tool ignores the @JoinColumn annotation in a @ManyToOne mapping if > the table argument is used > ----------------------------------------------------------------------------------------------------- > > Key: OPENJPA-201 > URL: https://issues.apache.org/jira/browse/OPENJPA-201 > Project: OpenJPA > Issue Type: Bug > Environment: 0.9.7-incubating-SNAPSHOT > Reporter: George Hongell > Priority: Minor > Attachments: Wine.java, Winery.java > > > @Entity > @Table(name="CxWine") > public class Wine { > @Id > private Integer wineid; > ... > @ManyToOne() > @JoinColumn(name="NEW_WINERY_WINERYID", referencedColumnName="WINERYID", > table="cxWinery") > //ignored @JoinColumn(name="NEW_WINERY_WINERYID", > referencedColumnName="WINERYID", table="cxWinery") > //ignored @JoinColumn(name="NEW_WINERY_WINERYID", > referencedColumnName="WINERYID", table="cxWinery") > //ignored @JoinColumn(name="NEW_WINERY_WINERYID", table="cxWINERY") > //ok @JoinColumn(name="NEW_WINERY_WINERYID", referencedColumnName="wineryid") > //ok @JoinColumn(name="NEW_WINERY_WINERYID") > private Winery winery; > ... > } > generates > 2744 cxwineTour TRACE [main] openjpa.jdbc.SQL - <t 1094861122, conn > 98698722> executing stmnt 1325027066 CREATE TABLE CxWine (wineid INTEGER NOT > NULL, cost SMALLINT, description VARCHAR(254), minimumHoldYears INTEGER, > rating SMALLINT, stockCount INTEGER, type VARCHAR(20), version INTEGER, > alcoholPercent DOUBLE, ava VARCHAR(40), bottler VARCHAR(40), brandName > VARCHAR(40), labelWineClass VARCHAR(20), labelWineColor VARCHAR(20), > estateBottled SMALLINT, hasSulfites SMALLINT, labelid INTEGER, mlContents > INTEGER, qualityDesignation VARCHAR(40), vineyardName VARCHAR(40), vintage > TIMESTAMP, wineName VARCHAR(40), winery_wineryid INTEGER, PRIMARY KEY > (wineid)) -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.