[hibernate-issues] [Hibernate-JIRA] Commented: (ANN-509) referencedColumnName to non primary key foreign key column causes MappingException

harry clark (JIRA) noreply at atlassian.com
Tue Dec 16 08:38:39 EST 2008


    [ http://opensource.atlassian.com/projects/hibernate/browse/ANN-509?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=31968#action_31968 ] 

harry clark commented on ANN-509:
---------------------------------

Unfortunately i think this problem is still with us, I have ~1360 persistent classes, using ~1100 compound key classes. I get the exception cited above

Exception in thread "main" java.lang.ExceptionInInitializerError
	at com.kve.util.HibernateUtil.<clinit>(HibernateUtil.java:1360)
	at com.kve.main.Main.main(Main.java:22)
Caused by: org.hibernate.MappingException: Unable to find column with logical name: SRZPT3 in org.hibernate.mapping.Table(D4TGCPP) and its related supertables and secondary tables

The relation in question is one to many. D4TGCPP has a one to many to the table in which SRZPT3 is a key. The mapping is

 @OneToMany(targetEntity=GT_EdfReleaseSeqPci.class)
  @JoinColumns({
    @JoinColumn(name="TGZPT3",referencedColumnName="SRZPT3"),
    @JoinColumn(name="TGGBC5",referencedColumnName="SRGBC5"),
    @JoinColumn(name="TGCCS5",referencedColumnName="SRCCS5"),
    @JoinColumn(name="TGCDS5",referencedColumnName="SRCDS5"),
    @JoinColumn(name="TGB3N4",referencedColumnName="SRB3N4"),
    @JoinColumn(name="TGWON4",referencedColumnName="SRWON4"),
    @JoinColumn(name="TGWIN4",referencedColumnName="SRWIN4")
  })
  public Set<GT_EdfReleaseSeqPci> gt_EdfReleaseSeqPci;

The mapped table has 8 keys; the one to many uses 7 of them, and they are correct.  When I move the enclosing table to be first in the configuration the same exception happens on a different, unrelated table. The enclosing table (D4TGCPP, named in the exception) is GT_EdfReleaseSeqPac; the one to many is below it in collating order,  GT_EdfReleaseSeqPci, not above it. 

The exc msg sort of implies that the join col is missing on the enclosing table, but that table is used is only one other mapping (one to many, as target). The mapping shown here is the only one contained in that table.

I can't imagine a simple example with this database, or on this server, for admin reasons. I'll see what else I can do; perhaps this gives someone ideas. Thanks

> referencedColumnName to non primary key foreign key column causes MappingException
> ----------------------------------------------------------------------------------
>
>                 Key: ANN-509
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-509
>             Project: Hibernate Annotations
>          Issue Type: Bug
>          Components: binder
>    Affects Versions: 3.2.0.ga
>         Environment: Hibernate 3.2.0.GA inside JBoss EJB install
>            Reporter: Matthew D. Frederes
>             Fix For: 3.3.1.CR1
>
>         Attachments: jiratest.ejb3, jiratest.ejb3
>
>
> See attached test ejb3 file.
> Using a referencedColumnName of fk column causes MappingException:
> org.hibernate.MappingException: Unable to find column with logical name: vendor_id in org.hibernate.mapping.Table(ItemCost) and its related supertables and secondary tables
>    @ManyToOne
>    @JoinColumns({
>      	@JoinColumn(name="vendor", referencedColumnName="vendor_id", insertable=false, updatable=false),
>      	@JoinColumn(name="item", referencedColumnName="item_id", insertable=false, updatable=false)
>      })     
>     public ItemCost getDefaultCost() {
>       return defaultCost;
>     }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list