Hibernate 3.2.3
MySql 5.0.41
hi, everyone,
i'm developing a project that needs to log every db operation into a table, for example, the log table maybe look as follows:
tb_name | oper_type | row_affacted
---------------------------------------------------
tb_user | insert | 1
tb_address | update | 3
---------------------------------------------------
that means i update 3 rows in tb_adderss and insert 1 row into tb_user in one transaction.
one solution is that i count the objects get from front-end and treat that as "row_affacted", but there is chance that may be one object is already in the tb_address.
for example: i get one TbUser, three TbAddress, but finally i only insert 1 into tb_user and update 2 for tb_address.
i also think about the trigger, but the trigger for Mysql is based on row level, which means i'll get TWO single line in log table for tb_address with the "row_affacted" as "1".
there is also a way that i can compare the objects with the records in the table to determine which operation will take, but isn't that too complicated??
is there a way i can get the table & row count DIRECTLY from the session?
thanks in advance
|