File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes Why a duplicate column being created for a foriegn key Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Why a duplicate column being created for a foriegn key " Watch "Why a duplicate column being created for a foriegn key " New topic
Author

Why a duplicate column being created for a foriegn key

Kumar Raja
Ranch Hand

Joined: Mar 18, 2010
Posts: 518
    
    2

Hi All,

I have a below class file and hbm file defined



As you see, it has an association with Stock class, which I'm omitting for now in this post.




When I looked into logs for org.hibernate.tool.hbm2ddl.SchemaExport, I see the create DDL statement for StockDailyRecord as follows



As you see, it has STOCK and STOCKID. Which are actually one and the same. and when you persist, the value is being duplicated in both the columns. This is not necessary. How can this be fixed?

Please advise.

Regards
KumarRaja

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Why a duplicate column being created for a foriegn key