-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: very strange problem, help pleas!
PostPosted: Sat Aug 12, 2006 11:49 am 
Newbie

Joined: Fri Jan 27, 2006 11:14 am
Posts: 12
Hi, i got such a strange problem that im sure you ll think im doin crazy talk :) , i dont see why this would happen at all, i have a class called "Package", mapped to a table "package". whenever i do a query on this table using hibernate, even the simplest "find all" kinda of query, hibernate does update on the table b4 doin the query! even more weird, it does the update when the first query on this table happens, it deletes all values of a column (yes only this column); then if i do the same query again, no update at all. however if now i mannuall add those missing values, it does the update again and deletes them! sry its confusing, heres my code and more of wat i done:

The mapping Package.hbm.xml

<hibernate-mapping package="tuition.bo">
<class name="Package" table="package">

<id name="id" column="study_package_id" type="long">
<generator class="sequence"/>
</id>

<property name="name" column="name" not-null="true"/>
<property name="satTiming" column="sat_timing" not-null="false"/>
<property name="satSubjects" column="sat_subjects" not-null="false"/>
<property name="sunTiming" column="sun_timing" not-null="false"/>
<property name="sunSubjects" column="sun_subjects" not-null="false"/>

<set name="classes" inverse="true" cascade="delete-orphan" lazy="true">
<key column="package_id"/>
<one-to-many class="Class"/>
</set>

</class>
</hibernate-mapping>

For example initialy i populated database using hibernate, like this:

package_id, name, sat_timing, sat_subjects, sun_timing, sun_subjects
1 no.1 9-12 business 9-12 law
2 no.2 9-11 business 9-11 law


Then after i populated this database, i did this query:

<b>List res=getHibernateTemplate().find("FROM Package");</b>

and you can see the log file as such: (excerpt)

16:23:06,687 INFO TransactionFactoryFactory:31 - Using default transaction strategy (direct JDBC transactions)
16:23:06,703 INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
16:23:09,968 DEBUG JDBCTransaction:46 - begin
16:23:09,968 DEBUG JDBCTransaction:50 - current autocommit status: true
16:23:09,968 DEBUG JDBCTransaction:52 - disabling autocommit

<b>16:23:10,640 DEBUG SQL:324 - select</b> studypacka0_.study_package_id as study1_, studypacka0_.name as name12_, studypacka0_.description as descript3_12_, ....... from _3AT_package studypacka0_
Hibernate: select studypacka0_.study_package_id as study1_, studypacka0_.name as name12_, studypacka0_.description as descript3_12_, studypacka0_.day as day12_, studypacka0_.sat_timing as sat5_12_, studypacka0_.sat_subjects as sat6_12_, .......

16:23:10,734 DEBUG JDBCTransaction:83 - commit
<b>16:23:10,796 DEBUG SQL:324 - update</b> _3AT_package set name=?, description=?, day=?, sat_timing=?, sat_subjects=?, sat_hours=?, sun_timing=?, sun_subjects=?, sun_hours=?, unit_price=?, years_id=?, group_id=? where study_package_id=?
Hibernate: update _3AT_package set name=?, description=?, day=?, sat_timing=?, sat_subjects=?, sat_hours=?, sun_timing=?, sun_subjects=?, sun_hours=?, unit_price=?, years_id=?, group_id=? where study_package_id=?
<b>16:23:10,812 DEBUG SQL:324 - update </b>_3AT_package set name=?, description=?, day=?, sat_timing=?, sat_subjects=?, sat_hours=?, sun_timing=?, sun_subjects=?, sun_hours=?, unit_price=?, years_id=?, group_id=? where study_package_id=?
Hibernate: update _3AT_package set name=?, description=?, day=?, sat_timing=?, sat_subjects=?, sat_hours=?, sun_timing=?, sun_subjects=?, sun_hours=?, unit_price=?, years_id=?, group_id=? where study_package_id=?
<b>16:23:10,812 DEBUG SQL:324 - update</b> _3AT_package set name=?, description=?,
...................................
16:23:10,953 DEBUG JDBCTransaction:173 - re-enabling autocommit
16:23:10,953 DEBUG JDBCTransaction:96 - committed JDBC Connection


as you can see, it does update and changed table field values to this:

package_id, name, sat_timing, sat_subjects, sun_timing, sun_subjects
1 no.1 business law
2 no.2 business law

---------- all tiimings are gone. and now if i re-do the same query, there are NO UPDATE operations....howver if i add some values to sat_timing, sun_timing, and re-do the query, very surprisingly, i saw those update operations which delete all timing values again!


im totally lost... i havent changed any config, this doenst happen to my other classes at all but just this one.... any ideas please! even some thought of what may caused this would be great help! thank you!


Top
 Profile  
 
 Post subject:
PostPosted: Sat Aug 12, 2006 12:12 pm 
Newbie

Joined: Fri Jan 27, 2006 11:14 am
Posts: 12
well i got the setters wrong.... being so stupid i am... sry for creating such a long and massy thread.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.