• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Having trouble in understanding bi directional relationships

 
Kumar Raja
Ranch Hand
Posts: 547
2
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,

To be honest with you, I have spent considerable amount of time in understanding the associations (specially bidirectional) but still not really able to understand the basics. I could not get a simple one to many bidirectional mapping to work and I need your help in understanding the mistake and a fix.

I have two classes Stock and StockDailyRecords. (These examples are taken straightly from example. My stock class is defined as below



Similarly StockDailyRecord is as follows


My entire mapping files are as below
Stock.hbm.xml


StockDailyRecord.hbm.xml


I'm facing two issues here
1) if I have same column in Set element of Stock and Many to One element of StockDailyRecord, I'm getting an exception
I'm not sure why I should make insert and update false here.

If I manage to change the name of the either of the columns say, from STOCK_FK_ID to STOCK_ID (Which does not make any sense to me here? Why?), I get another error


while trying to persist Stock and StockDailyRecord.

My client looks like below


create(Object) method looks as below



How do I persist both the records. When I run my client, I'm successful in persisting only Stock, but not StockDailyRecord. How do I make sure that upon persisting Stock, it should also persist StockDailyRecord without using Cascase option.

Does it make any difference in using "inverse" attribute ?

Please help me
 
Kumar Raja
Ranch Hand
Posts: 547
2
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can some body take a look at my question and help me understand that ?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic