Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

@JoinColumn referencedColumnName

843830Sep 22 2009 — edited Sep 28 2009
Hi,

I wanted to explicitly specify the referencedColumnName so that the developers can easily figure out which column I am joining to.

Following is the code snippet.
   class ProductSpecification {
      .......

       @ManyToOne
	//@JoinColumn(name = "\"OWNER\"",referencedColumnName  = "\"ID\"", table="\"PRODUCTCATEGORY\"")
	//@JoinColumn(name = "\"OWNER\"",referencedColumnName  = "id")	
        //@JoinColumn(name = "\"OWNER\"",referencedColumnName  = "\"ID\"")
	@JoinColumn(name = "\"OWNER\"")
	private ProductCategory productCategory;
     ...........
   }
If I don't specify the referencedColumnName, there is no problem. It takes default primary key of the ProductCategory table.

If explicit definition is specified, I get the following errors. For individually for every commented code line, i get the respective run time error.

"Caused by: org.hibernate.AnnotationException: Cannot find the expected secondary table: no "PRODUCTMGMT" available for ProductSpecification"

"Caused by: org.hibernate.MappingException: Unable to find column with logical name: id in org.hibernate.mapping.Table("PRODUCTCATEGORY") and its related supertables and secondary tables"

"Caused by: org.hibernate.AnnotationException: Column name ID of ProductCategory not found in JoinColumns.referencedColumnName"

Could you please help me on the reason.

Thanks,
Rajesh
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 26 2009
Added on Sep 22 2009
3 comments
2,500 views