edit 5/11/2011:
i guess it's bit worse what's below; in deployed qa instance, if refresh main dashboard number of times, user's many-to-many group associations deleted. @ point, there select statements being called on server side; i'm getting narrowed down these latest tests.
original:
hi all. i'm having problem rather complex object; problem follows: when send object client server saved, seemingly randomly wiping out many-to-many relationships on associated objects. worse yet, not able reproduce problem myself, after 2 months of being aware of problem. have app out testing qa group; they're using program daily, double entering in new , legacy applications. problem crops as 3 times day.
i'll best provide detail can, , appreciate taking look!
the app framework gwt 2.1 + gilead + hibernate 3 + mysql innodb. i'm letting hibernate handle cascading etc, none defined in db, although foreign keys set in db.
here's excerpts mappings:
<hibernate-mapping> <class name="com.example.domain.close" table="close"> <many-to-one name="updateuser" class="com.example.domain.user" column="last_update_user"/> </class> </hibernate-mapping> <hibernate-mapping> <class name="com.example.domain.user" table="user" batch-size="25"> <set name="groups" table="user_group" lazy="true" batch-size="25"> <key column="user_id"/> <many-to-many column="group_id" class="com.example.domain.group"/> </set> </class> </hibernate-mapping> <hibernate-mapping> <class name="com.example.domain.group" table="group" batch-size="25"> <set name="users" table="user_group" lazy="true" inverse="true"> <key column="group_id"/> <many-to-many column="user_id" class="com.example.domain.user"/> </set> <set name="permissions" table="permission_group" lazy="true" inverse="true"> <key column="group_id"/> <many-to-many column="permission_id" class="com.example.domain.permission"/> </set> <hibernate-mapping> <class name="com.example.domain.permission" table="permission"> <set name="groups" table="permission_group" lazy="true"> <key column="permission_id"/> <many-to-many column="group_id" class="com.example.domain.group"/> </set> </class> </hibernate-mapping>
saving object simple call saveorupdate():
session session = gileadhibernateutil.getsessionfactory() .getcurrentsession(); session.begintransaction(); try { session.saveorupdate(close); } catch (exception e) { e.printstacktrace(); session.gettransaction.rollback(); } session.gettransaction.commit(); return close;
the close 'updateuser' object loaded when user logs in. loaded associated groups , permissions system can grant/deny access app modules. do
close.setupdateuser(exampleapp.getuser());
before sending object server.
there plenty of other places in app sort of operation happens, doesn't cause unwanted side-effects. boils down complexity of client-side code associated close object, or rather, implementation of it.
i've spent time pouring on official hibernate docs, looking possibly related problems, etc, thought maybe time ask help. have man , keep @ it, maybe asking me figure out.
i'm not sure else provide right that's relevant. here far has relevance!
thanks listening!
edit
may 5 12:18:38 localhost jsvc.exec[10117]: hibernate: insert example_dev.recent_item (object_type, object_id, date, user_id) values (?, ?, ?, ?) may 5 12:18:38 localhost jsvc.exec[10117]: hibernate: delete example_dev.permission_group permission_id=? may 5 12:18:38 localhost last message repeated 19 times may 5 12:18:38 localhost jsvc.exec[10117]: hibernate: delete example_dev.user_group user_id=? may 5 12:18:38 localhost jsvc.exec[10117]: hibernate: delete example_dev.user_designation user_id=?
it appears deletes happening right after insert.. previous operations selects. nothing in user should cascading recentitem.
after lot of research, came conclusions , able take action. first off, learned after quite bit of searching on gilead forum, no longer being actively maintained. should have noticed sooner. meanwhile, had started reading requestfactory, , after couple days of research, decided should try migrating this.
this rather large project, 50 domain objects, many object associations. took me around 40-50 hours rewrite using gilead + gwt rpc using requestfactory exclusively. pretty happy resulting changes in code , structure. i'm not bothered far having create dto proxy objects, , took opportunity switch hibernate annotations, getting rid of mapping files.
it tricky @ times refactor code utilize fetch/edit/save cycles requestfactory requires. did give me opportunity improve upon of code.
the news is, problem has been resolved. no more many-to-many associations being mysteriously deleted. best guess hitting bug in gilead, or usage of incorrect, or possible resolved problem when migrating annotations.
i ran across great resources while learning requestfactory+hibernate, many through stackoverflow (thanks again!):
using gwt requestfactory objectify - great feel how requestfactory interacted backend, , methods , boilerplate cut down on code.
more links below hopefully.. i'm still noob limited in # of hyperlinks can post :)
i learned lot, , getting fluent in requestfactory. i'll best keep eye out , out here think can.
thanks stackoverflow!
Comments
Post a Comment