i'm having now another problem. I want to add a new Benutzer and assign a profile to it.
So i'm getting an existing Profil Object with hibernate and fill this Profile into the Set, afterwards I assign this Set to the Benutzer Object.
Code:
Benutzer benutzer = new Benutzer();
benutzer.setBenutzerName(benutzerName);
benutzer.setPasswort(passwort);
benutzer.seteMail(emailAdresse);
benutzer.setMutUser(benutzerName);
benutzer.setPersonId(new Integer(persId));
benutzer.setAnzahlLogin(new Integer(0));
benutzer.setBenutzerStatus(benutzerManager.getBenutzerStatus(new Integer(1)));
// add benutzer to the userProfile!
Profil profil = benutzerManager.getProfil(ProfilTyp.USER);
Set profileSet = new HashSet();
profileSet.add(profil);
benutzer.setProfile(profileSet);
Then when saving the Benutzer object in the Manager Class I'm getting this exception (using hibernate with spring):
Code:
2006-05-02 11:56:25,115 ERROR Could not synchronize database state with session in (AbstractFlushingEventListener.java:300)
org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [najsre7.model.Benutzer#51]
at org.hibernate.persister.entity.AbstractEntityPersister.check(AbstractEntityPersister.java:1635)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2208)
at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2118)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2374)
these are the sql statements hibernate is executing:
Code:
insert into NAJSRE7_WEB.TBENUTZER
(DMUTDAT,FK_TBENUSTAT_ISTATUS,SBENUTZERNAME,SPASSWORT,SEMAIL,DLASTLOGIN,IANZLOGIN,SMUTUSER,SSTVUSER,FK_TPER_IPERSNR,ILAUFNUMMER) VALUES
(? ,? ,? ,? ,? ,? ,? ,? ,? ,? ,? )
update NAJSRE7_WEB.TBENUTZER set DMUTDAT=?,
FK_TBENUSTAT_ISTATUS=?,
SBENUTZERNAME=?,
SPASSWORT=?,
SEMAIL=?,
DLASTLOGIN=?,
IANZLOGIN=?,
SMUTUSER=?,
SSTVUSER=?,
FK_TPER_IPERSNR=?
where ILAUFNUMMER=?
and DMUTDAT=?
I can't see any SQL insert statement from the join table TBENU_PROFIL_MATRIX ! :-(
Did i something wrong in the mapping file? Do i have to define a cascade or inverse attribute?
kind regards
angela