• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

how hibernate cover the problem of duplication data ?

 
Ranch Hand
Posts: 472
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, i would like to ask how hinerate to detect duplication of data ?

for example, i use the following to save


due to using <generator class="increment"/> in mapping file, it does save the records by increment the id, in my case, only id column is unique but other column in db with have same, of course this cause by the way i set the data into object,

but let say i make my program save the data in dynamic way which means the data based on user actions, but how we make sure the data is not duplicate in database? so that when we query database, it won't give many records with same data ..is there anyway to control this ?
[ October 28, 2005: Message edited by: Nakata kokuyo ]
 
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To avoid adding additional rows, you'll need to query the database to find any objects that match the one you are about to save.

Hibernate's Query By Example makes this pretty easy.
 
Ranch Hand
Posts: 207
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Scott is correct. This is business-logic anyhow and does not belong in the database.
 
Nakata kokuyo
Ranch Hand
Posts: 472
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you , scott n vinnie
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
using unsaved-value parameter of the ID tag, check the value is null or not.
If Id value is null, using saveorupdate method it will insert the data.
If Id value is not null it will update the data.
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic