Hello guys,
Ok, ill rephrase my entire post. hehe
i am working on a project which involve intensive monetary transactions,
thus i really need to secure each transaction.
I want to perform a record locking and timestamping on each transaction.
for instance, user1 and user2 access a single record at the same time.
then, user1 saves his changes. While user1's transaction (of saving his changes)
is on going, i would like that record to be locked.
once the transaction is done (the changes are committed to the database) and the timestamp
is updated for that record (timestamp is done via triggers and is done before insert), the changes now
will be available to user2 and thus, since there are changes on the timestamp, he can not proceed to his transaction.
how can i set the locking up on hibernate.
here is my hibernate.cfg.xml
Code:
<session-factory>
<property name="connection.username">root</property>
<property name="connection.url">jdbc:mysql://localhost:3306/employee</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="myeclipse.connection.profile">MySQL</property>
<property name="connection.password">root</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.autocommit">true</property>
<!-- Connection Pooling config, using cp30 -->
<property name="hibernate.c3p0.max_size">1</property>
<property name="hibernate.c3p0.min_size">1</property>
<property name="hibernate.c3p0.timeout">5000</property>
<property name="hibernate.c3p0.max_statements">0</property>
<property name="hibernate.c3p0.acquire_increment">3</property>
<property name="hibernate.c3p0.idle_test_period">300</property>
<mapping class="com.xxx.model.User" />
<mapping class="com.xxx.model.Role" />
</session-factory>
and here is my applicationContext.xml
Code:
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="configLocation" value="classpath:hibernate_employee.cfg.xml" />
</bean>
<bean class="org.springframework.orm.hibernate3.HibernateTransactionManager" id="transactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<bean class="com.goldenway.action.UserAction" id="UserAction" scope="prototype" >
<property name="manager" ref="manager"/>
<property name="userManager" ref="userManager" />
</bean>
please advise....
i have tried using hibernate before, but i have not tried setting it up. usually, my seniors are the one to set the hibernate environment up.
and now, this is my first time doing it myself. please go easy on me. thanks
marckun
*note above codes are mock examples.