We have two java applications: both read / write and 3 standalone Java read / write applications (one downloads questions via e-mail, one processes the XML channel, one sends letters to subscribers), all use sleep mode and use a common database code.
The problem we recently encountered is that questions downloaded by email sometimes overwrite questions created in one of the web applications. Please note that these are separate questions that must have a separate identifier. Initially, we thought it was a cache problem. We tried to disable the second level cache, but it does not matter.
<property name="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property> <property name="hibernate.current_session_context_class">thread</property> <property name="hibernate.cache.use_second_level_cache">false</property>
Question:
@Id @GeneratedValue(strategy = IDENTITY) @Column(name = "id", unique = true, nullable = false) @DocumentId public Integer getId() { return this.id; }
We use MySQL btw.
CREATE TABLE `question` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, ... PRIMARY KEY (`id`), ... ) ENGINE=InnoDB DEFAULT CHARSET=utf8
We do not open or close sessions, but let hibernate manage them through Util.getSessionFactory().getCurrentSession() .
We do not want to tune the second-level cluster cache at this stage, since this creates another level of complexity, and we are more than happy with the level of performance that we receive from the application as a whole.
So does the implementation of the open-session-in-view template in web applications and manual session management in stand-alone applications do it as if to fix it?
Or any other suggestions / ideas please?
source share