• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

concurrent insertion

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi I have scenario where

operation 1: 2 user read data from table1 and table2

table3 is a link table for table1 and table2 which has foreign keys of table1 and table2.

operation2: the first user has inserted a new record in table3
operation3: later the second user is also inserting a new record in table3 which is not aware already a record is inserted

I am using hibernate mapping but we are not using hibernate version check ....................

How to prevent multiple record in table3?

in mapping files or for every insertion I have to check already a record in table3?

How should be the mappings file declared?

I just changed the names of mapping ..........
<hibernate-mapping>
<class name=" " table="table3_LINK">
<meta attribute="extends" inherit="false">BaseModel</meta>
<meta attribute="class-code" inherit="false">private static final long serialVersionUID = 1L;</meta>
<id name="id" type="java.lang.Long">
<column name="table3_ID" precision="15" scale="0" />
<generator class="identity"></generator>
</id>
<many-to-one name="Employer" class=".model.businessobject.table1" fetch="select">
<column name="FK_table1_ID" precision="15" scale="0" not-null="true" />
</many-to-one>
<many-to-one name="rc" class=".model.businessobject.table2" fetch="select">
<column name="FK_table2_ID" precision="15" scale="0" not-null="true" />
</many-to-one>
<property name="intPartyInd" type=".model.hibernateext.TrimmedString">
<column name="column3_table3" length="1" not-null="true" />
</property>
<property name="mailto1Ind" type=".model.hibernateext.TrimmedString">
<column name="Column4_table4" length="1" not-null="true">
</column>
</property>









 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Would you not just use a unique index on your link table?
 
tej ku
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to make combination of two Foreign keys in table3 unique.
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK. So would you not just use a unique index on your link table?
 
tej ku
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you give me a example of how hibernate mappling file should look like.........
 
tej ku
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I guess we can make multiple column unique by two ways "composite-id" and "unique-key".......What is the difference between using "composite-id" and "unique-key" constraint?
 
You showed up just in time for the waffles! And this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic