I have a problem with Hibernate... consider the following mapping (incomplete, I hope this is the relevant part):

<class name="it.satanet.ketpl.model.PriceList" table="price_list">
    <id name="id" column="id" type="long">
      <generator class="vm.long"/>
    </id>
    <property name="date" column="pl_date" type="date"/>
    <property name="active" type="boolean" not-null="true"/>
    <property name="supplyConditions" column="supply_cond"
              type="string" length="1000"/>
    <property name="revNumber" column="rev_number" type="integer"/>
    <property name="year" column="pl_year" type="short"/>
    <many-to-one name="customer" column="customer_id" not-null="true"
                 class="it.satanet.ketpl.model.Customer"/>
    <bag role="items" readonly="true" lazy="true">
        <key type="long" column="pricelist_id"/>
        <one-to-many class="it.satanet.ketpl.model.PriceListItem"/>
    </bag>
  </class>

<class name="it.satanet.ketpl.model.PriceListItem" table="pricelist_item">
<id name="id" column="id" type="long" unsaved-value="null">
<generator class="vm.long"/>
</id>
<property name="gross" type="big_decimal" length="2"/>
<property name="discount1" type="double"/>
<property name="discount2" type="double"/>
<property name="net" type="big_decimal" length="2"/>
<property name="packing" type="big_decimal" length="2"/>
<property name="note" type="string"/>
<property name="rise" type="double"/>
<property name="novelty" type="boolean" not-null="true"/>
<many-to-one name="article" column="article_id" not-null="true"
class="it.satanet.ketpl.model.Article"/>
<many-to-one name="priceList" column="pricelist_id" not-null="true"
class="it.satanet.ketpl.model.PriceList"/>
</class>



When I try the following command to purge the database contents hibernate goes nuts (this is included in a stateless session bean
method, with container managed transactions):


             s = sf.openSession();
             s.delete("from x in class " + PriceListItem.class);
             s.delete("from x in class " + PriceList.class);
             s.flush();

After the flush I see on the trace a whole lot of infos like
hidrating entity PriceListItem xxx and the a whole lot of
excuting bactch in which the command is an update, and after some
thousands useless updates the entities gets deleted... why oh why
is Hibernate updating the db and trying to load into memory these
object when all I have asked is to delete them?

Ah, I've noticed that inserting a new PriceList is quite slow (each
price list includes something like 100 items), the batch update
seems to take forever with no CPU consuption at all... I'm running
the following command (into a stateless session bean):

public void insert(PriceList pl) throws SaveException {
       Session s = null;

try {
s = HibernateUtils.getSession();
s.save(pl);
List items = pl.getItems();
if(items != null) {
for(Iterator it = items.iterator(); it.hasNext(); ) {
s.save(it.next());
}
}
s.flush();
} catch (Exception e) {
mLog.error("Error while inserting new object:\n" + HibernateUtils.xmlEncode(pl), e);
mContext.setRollbackOnly();
throw new SaveException("Object insert failed", e);
} finally {
try {s.close();} catch(Exception e) {e.printStackTrace();}
}
}


Hibernate is running as a JMX service in JBoss 3.0.2, the db is SAPDB,
I'm using container managed transactions and stateless session bean,
platform is windows 2000 professional...


Best regads Andrea Aime



-------------------------------------------------------
This sf.net email is sponsored by: Influence the future of Java(TM) technology. Join the Java Community Process(SM) (JCP(SM)) program now. http://ad.doubleclick.net/clk;4729346;7592162;s?http://www.sun.com/javavote
_______________________________________________
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel




Reply via email to