powered by simpleCommunicator - 2.0.61     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / Java [игнор отключен] [закрыт для гостей] / Extended session and automatic versioning
1 сообщений из 1, страница 1 из 1
Extended session and automatic versioning
    #38856724
Alacarte
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Добрый день, сразу вопрос

After reconnection, to force a version check on data you are not updating, you can call Session.lock() with LockMode.READ on any objects that might have been updated by another transaction. You do not need to lock any data that you are updating. Usually you would set FlushMode.MANUAL on an extended Session, so that only the last database transaction cycle is allowed to actually persist all modifications made in this conversation. Only this last database transaction will include the flush() operation, and then close() the session to end the conversation.

насколько я понимаю тут имеется ввиду что сессия по всему приложению есть одна, при user think time jdbc конекшн обернутый в сессию просто возвращается в пул, синхронизация с базой происходит при каждой последующей транзакции, типа есть несколько транзакций только одна из них комитит, а остальные только read only, допустим у меня есть DAO метод типа:

Код: java
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
	public void create(User user) throws DaoException, UserConstraintException {
		Session session = null;
		try {
			session = HibernateUtil.getSessionFactory().getCurrentSession();
			session.beginTransaction();
			session.save(user);
			session.getTransaction().commit();
		} catch (HibernateException e) {
			session.getTransaction().rollback();
			if (e instanceof ConstraintViolationException) {
				throw new UserConstraintException(
						"User with such login exist already...", null);
			}
			throw new DaoException(null, e);
		}
	}


в общем я не совсем понимаю как реализовать этот паттерн, кто может линканите на ресурс где можно подробно почитать
...
Рейтинг: 0 / 0
1 сообщений из 1, страница 1 из 1
Форумы / Java [игнор отключен] [закрыт для гостей] / Extended session and automatic versioning
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]