• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

Having trouble in understanding bi directional relationships

 
Ranch Hand
Posts: 558
2
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 558
2
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can some body take a look at my question and help me understand that ?
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic