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:

List res=getHibernateTemplate().find("FROM Package");

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

16:23:10,640 DEBUG SQL:324 - select 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
16:23:10,796 DEBUG SQL:324 - 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=?
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=?
16:23:10,812 DEBUG SQL:324 - 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=?
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=?
16:23:10,812 DEBUG SQL:324 - update _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!

-- 
View this message in context: 
http://www.nabble.com/help-pls%2C-very-strange-problem-tf2095717.html#a5776809
Sent from the Hibernate forum at Nabble.com.


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
hibernate-devel mailing list
hibernate-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/hibernate-devel

Reply via email to