Привет я пытался решить, но я не в состоянии решить егоorg.springframework.orm.hibernate3.HibernateSystemException: другой объект с тем же значением идентификатора уже был связан с сессией
получение исключение как этот
org.springframework.orm.hibernate3.HibernateSystemException: a different object with the same identifier value was already associated with the session:
[com.omnypay.dao.bo.CloudSvrUsersProfile#284]; nested exception is org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [com.omnypay.dao.bo.CloudSvrUsersProfile#284]
Вызванный:
org.hibernate.NonUniqueObjectException: a different object with the same identifier value was
already associated with the session:
мой класс пользователь
@Entity
@Table(name="CLOUD_SVR_USERS")
@NamedQuery(name="CloudSvrUser.findAll", query="SELECT c FROM CloudSvrUser c")
public class CloudSvrUser implements Serializable {
@Id
@GeneratedValue
@Column(name="USER_ID")
private long userId;
it has some column and the oneto one relation like
@OneToOne(mappedBy="user",fetch=FetchType.LAZY,cascade=CascadeType.ALL)
private CloudSvrUsersProfile usersProfile;
and getters&setters
и мой профиль класса
@Entity
@Table(name="CLOUD_SVR_USERS_PROFILE1")
@NamedQuery(name="CloudSvrUsersProfile.findAll", query="SELECT c FROM CloudSvrUsersProfile c")
public class CloudSvrUsersProfile implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(name="USER_ID",nullable=false)
@GeneratedValue(generator="gen")
@GenericGenerator(name="gen", strategy="foreign", [email protected](name="property", value="user"))
private Long usersProfileId;
//columns and
@OneToOne
@PrimaryKeyJoinColumn
private CloudSvrUser user;
@Transient
private String emailId;
и класс обслуживания осущ является
@Transactional
public void UpdateUserProfile(CloudSvrUsersProfile userProf) throws BusinessException
{
try{
CloudSvrUser dbUser = getUser(userProf);
//CloudSvrUsersProfile dbUserProfile = dbUser.getUsersProfile();
//CloudSvrUsersProfile updatedProf=userProf.getUsersProfile();
if(dbUser != null){
//CloudSvrUsersProfile newUserInfoList = new CloudSvrUsersProfile();
//CloudSvrUsersProfile newUserInfoList = CloudSvrUsersProfile();
CloudSvrUsersProfile updatedProf = new CloudSvrUsersProfile();
updatedProf.setFirstName(userProf.getFirstName());
updatedProf.setLastName(userProf.getLastName());
updatedProf.setAddress1(userProf.getAddress1());
updatedProf.setAddress2(userProf.getAddress2());
updatedProf.setAddress3(userProf.getAddress3());
updatedProf.setZipCode(userProf.getZipCode());
updatedProf.setState(userProf.getState());
//
updatedProf.setStatus(Long.parseLong("1"));
updatedProf.setCreatedBy(Long.parseLong("1"));
updatedProf.setCreatedDate(new Timestamp(System.currentTimeMillis()));
//updatedProf.setEmialId(userProf.getEmialId());
dbUser.setEmailId(userProf.getEmailId());
dbUser.setUsersProfile(updatedProf);
updatedProf.setUser(dbUser);
updateuser(dbUser);
}
}
catch(DaoException daoException) {
throw new BusinessException(daoException.getMessage());
}
}
для 1-го запроса его ввода данных в БД, но и для второго, когда я меняюсь какую-то ценность и попробовать ударить db из моего url, давая вышеуказанное исключение
Пожалуйста, помогите мне
почтовый индекс для вашей услуги и т. Д. –
Просьба вставить код, вызывающий эту проблему? – zerocool
try \t {// \t \t super.getHibernateTemplate(). Save (пользователь); \t \t //super.getHibernateTemplate().saveOrUpdate(user); \t \t //super.getHibernateTemplate().update(user); \t \t //this.userDao.updateUser(dbUser); \t \t \t \t \t} \t улов (DataAccessException accessException) { \t \t \t \t бросить новый DaoException ("Произошла внутренняя ошибка DB."); \t \t \t} – smita