Hibernate version:2.1.7
Name and version of the database you are using:Oracle 9i
Simplify...
I must load an object DAY when it does not exist or I must create it if it does not exist previously.
This happens to the arrival of a message on a MDB.
I use BEA and the relative DataSource.
The problem is that on the contemporary arrival of the messages they create more table-row for the same day and this does not have to happen.
How I resolve the synchronization problem?
Someone have advised to me to insert UNIQUE constraint on the DB and to manage the exception of the duplication of such field.
What is the correct way to proceed?
Help me, please!
This is the sample code...
day = getDay(day, session);
if (day == null) {
Transaction tx = null;
try {
day = new Day(Calendar.getInstance);
day.setCreatorUser("system");
day.setStatus(DayStatus.SOURCE_UNAVAILABLE);
tx = ss.beginTransaction();
session.save(dayW);
tx.commit();
}
catch (Exception e) { ... }
|