-->
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: What does hibernate think is "dirty" here?
PostPosted: Tue Jan 10, 2006 1:42 am 
Regular
Regular

Joined: Mon Nov 14, 2005 7:33 pm
Posts: 73
I can't select a simple list of objects w/o an update happening for each record selected...and I can't put my finger on *why* this would be happening.

...the Order mapping:

Code:
<hibernate-mapping>
   <class name="com.portlets.bol.Order" table="sr_order">
     <id name="Id" column="order_id" type="long" unsaved-value="0">
      <generator class="identity" />
    </id>
     <property name="TransporterId" column="transporter_id" />
      <property name="PickListId" column="inv_pick_list_id" />
      <property name="CustomerId" column="cust_id" />
      <property name="OrderDate" column="order_date" />
      <property name="SentDate" column="sent_date" />
      <property name="Name" column="to_name" />
      <property name="Address1" column="to_addr1" />
      <property name="Address2" column="to_addr2" />
      <property name="City" column="to_city" />
      <property name="State" column="to_state" />
      <property name="Country" column="to_country" />
      <property name="PostalCode" column="to_postalcode" />
   </class>
</hibernate-mapping>


When I run through the records like so, the updates happen.

Code:
List<Order> orders = Orders.getByDateRange(beginDate, endDate);
      
//orders
for (Order o : orders)
{
  ...
}


Here's the method being called:

Code:
  public List<Order> getByDateRange(Date beginDate, Date endDate)
  {
    Session s = HibernateUtil.getCurrentSession();
   
    Criteria c = s.createCriteria(Order.class);
    c.add(Expression.between("SentDate", beginDate, endDate));

      return (List<Order>)c.list();
  }


I get these queries:

Code:
Hibernate: select this_.order_id as order1_10_0_, this_.transporter_id as transpor2_10_0_, this_.inv_pick_list_id as inv3_10_0_, this_.cust_id as cust4_10_0_, this_.order_date as order5_10_0_, this_.sent_date as sent6_10_0_, this_.to_name as to7_10_0_, this_.to_addr1 as to8_10_0_, this_.to_addr2 as to9_10_0_, this_.to_city as to10_10_0_, this_.to_state as to11_10_0_, this_.to_country as to12_10_0_, this_.to_postalcode as to13_10_0_ from sr_order this_ where this_.sent_date between ? and ?
Hibernate: update sr_order set transporter_id=?, inv_pick_list_id=?, cust_id=?, order_date=?, sent_date=?, to_name=?, to_addr1=?, to_addr2=?, to_city=?, to_state=?, to_country=?, to_postalcode=? where order_id=?
Hibernate: update sr_order set transporter_id=?, inv_pick_list_id=?, cust_id=?, order_date=?, sent_date=?, to_name=?, to_addr1=?, to_addr2=?, to_city=?, to_state=?, to_country=?, to_postalcode=? where order_id=?
Hibernate: update sr_order set transporter_id=?, inv_pick_list_id=?, cust_id=?, order_date=?, sent_date=?, to_name=?, to_addr1=?, to_addr2=?, to_city=?, to_state=?, to_country=?, to_postalcode=? where order_id=?
Hibernate: update sr_order set transporter_id=?, inv_pick_list_id=?, cust_id=?, order_date=?, sent_date=?, to_name=?, to_addr1=?, to_addr2=?, to_city=?, to_state=?, to_country=?, to_postalcode=? where order_id=?
Hibernate: update sr_order set transporter_id=?, inv_pick_list_id=?, cust_id=?, order_date=?, sent_date=?, to_name=?, to_addr1=?, to_addr2=?, to_city=?, to_state=?, to_country=?, to_postalcode=? where order_id=?
Hibernate: update sr_order set transporter_id=?, inv_pick_list_id=?, cust_id=?, order_date=?, sent_date=?, to_name=?, to_addr1=?, to_addr2=?, to_city=?, to_state=?, to_country=?, to_postalcode=? where order_id=?
Hibernate: update sr_order set transporter_id=?, inv_pick_list_id=?, cust_id=?, order_date=?, sent_date=?, to_name=?, to_addr1=?, to_addr2=?, to_city=?, to_state=?, to_country=?, to_postalcode=? where order_id=?
Hibernate: update sr_order set transporter_id=?, inv_pick_list_id=?, cust_id=?, order_date=?, sent_date=?, to_name=?, to_addr1=?, to_addr2=?, to_city=?, to_state=?, to_country=?, to_postalcode=? where order_id=?
Hibernate: update sr_order set transporter_id=?, inv_pick_list_id=?, cust_id=?, order_date=?, sent_date=?, to_name=?, to_addr1=?, to_addr2=?, to_city=?, to_state=?, to_country=?, to_postalcode=? where order_id=?


Every call thereafter I get only the query I would have expected...even if I restart tomcat:

Code:
Hibernate: select this_.order_id as order1_10_0_, this_.transporter_id as transpor2_10_0_, this_.inv_pick_list_id as inv3_10_0_, this_.cust_id as cust4_10_0_, this_.order_date as order5_10_0_, this_.sent_date as sent6_10_0_, this_.to_name as to7_10_0_, this_.to_addr1 as to8_10_0_, this_.to_addr2 as to9_10_0_, this_.to_city as to10_10_0_, this_.to_state as to11_10_0_, this_.to_country as to12_10_0_, this_.to_postalcode as to13_10_0_ from sr_order this_ where this_.sent_date between ? and ?


However, if I reload the data from production to my dev box and start fresh...the updates happen again!

Also, this all happens within one session and one transaction...nothing gets disconnected.

There's nothing wrong w/ the data so far as I can tell and I'm just stumped...any ideas?

Thanks!



Hibernate version: 3.1

Name and version of the database you are using: MSSQL 2000


Top
 Profile  
 
 Post subject: oops!
PostPosted: Tue Jan 10, 2006 1:48 am 
Regular
Regular

Joined: Mon Nov 14, 2005 7:33 pm
Posts: 73
I goofed here and posted in the wrong forum...can someone move this to Hibernate Users...I'm using Hibernate not NHibernate...

Sorry!


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.