I have a single table, with a single PK, mapped to a single object...as plain vanilla as you can possibly get with hibernate...however...I am getting an update for every row that is selected...this is blowing my mind!
I'm simply calling a list of records inside of a single, open session & transaction and trying to display the results.
The class:
Code:
package com.bol;
import java.util.Date;
public class Order
{
private long id;
private long transporterId;
private long pickListId;
private String customerId;
private Date orderDate;
private Date sentDate;
private String name;
private String address1;
private String address2;
private String city;
private String state;
private String country;
private String postalCode;
public Order()
{
}
public long getId()
{
return id;
}
public void setId(long id)
{
this.id = id;
}
public long getTransporterId()
{
return transporterId;
}
public void setTransporterId(long transporterId)
{
this.transporterId = transporterId;
}
public long getPickListId()
{
return pickListId;
}
public void setPickListId(long pickListId)
{
this.pickListId = pickListId;
}
public String getCustomerId()
{
return customerId;
}
public void setCustomerId(String customerId)
{
this.customerId = customerId;
}
public Date getOrderDate()
{
return orderDate;
}
public void setOrderDate(Date orderDate)
{
this.orderDate = orderDate;
}
public Date getSentDate()
{
return sentDate;
}
public void setSentDate(Date sentDate)
{
this.sentDate = sentDate;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public String getAddress1()
{
return address1;
}
public void setAddress1(String Address1)
{
this.address1 = address1;
}
public String getAddress2()
{
return address2;
}
public void setAddress2(String Address2)
{
this.address2 = address2;
}
public String getCity()
{
return city;
}
public void setCity(String city)
{
this.city = city;
}
public String getState()
{
return state;
}
public void setState(String state)
{
this.state = state;
}
public String getCountry()
{
return country;
}
public void setCountry(String country)
{
this.country = country;
}
public String getPostalCode()
{
return postalCode;
}
public void setPostalCode(String postalCode)
{
this.postalCode = postalCode;
}
}
The hbm.xml file
Code:
<hibernate-mapping>
<class name="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>
The calling code
Code:
Criteria c = session.createCriteria(Order.class);
List<Order> orders = c.list();
for (Order o : orders)
{
....
}
For SOME reason, an update is issued for every single record when this runs! What's up w/ that? Is it seeing the records as dirty? This makes no sense and is the ONLY class in my entire domain that is behaving like this...it just doesn't make sense to me.
I have another class that's structured EXACTLY the same way, called Customer...which when used like the Order object is above....doesn't do the updating!
Hibernate version: 3.1
Name and version of the database you are using: MSSQL 2000