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