-->
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: Hbernate,MySQL, JBoss, or Gremlins ??
PostPosted: Wed Jun 20, 2007 3:51 pm 
Newbie

Joined: Mon May 14, 2007 12:13 pm
Posts: 8
The architecture is:
MDB.onMessage()->Stateless SessionBean->DAO
All of this in the context of BMT.

Hibernate version: 3.2.4sp1

Mapping file:


<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping package="com.spbase.model">

<class name="FrameOrder" table="FRAME_ORDER">
<id name="key" column="FRAME_ORDER_PK"/>

<property name="orderNumber" not-null="true"/>
<property name="owningFacility" not-null="true"/>
<property name="creationDate" not-null="true"/>
<property name="state" not-null="true"/>


<list name="transactionCollection" table="FRAME_ORDER_TRANSACTION" cascade="all">
<key column="FRAME_ORDER_PK"/>
<list-index column="collIndex"/>
<many-to-many column="TRANSACTION_ID" class="FrameTransaction"/>
</list>

</class>

</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
The DAO has one method
Code:
public void saveUsing(OrderTransaction anOrderTransaction){

       .....Ommitted code to look up the SessionFactory and other Exception handling stuff
   
   
         UserTransaction utx = (UserTransaction) iniCtx.lookup*("java:comp/UserTransaction");
   
    utx.begin();
     
         Session hibSess = sessFact.getCurrentSession();

         /*
         Check to see if an existing order exists
        */

   FrameOrder order = hibSess.get(FrameOrder.class,anOrderTransaction.getOrderNumber());

        if(order == null){
                log.info("creating a new FrameOrder using order# " + anOrderTransaction.getOrderNumber());

      order = new FrameOrder(anOrderTransaction.getOrderNumber());
        }

   order.add(anOrderTransaction);
        hibSess.saveOrUpdate(order);
   utx.commit();

        log.info("saved FrameOrder # " + anOrderTransaction.getOrderNumber());

}



I have some test transactions with duplicate order numbers, but, different transaction numbers. That is part of the business domain.

When the above code is executed. I see in the log entries that "creating a new FrameOrder using order# "AA227789" appears multiple times. When it clearly should NOT, since I'm checking to see if this order exists before creating a new one. By, all indications the order should have been persisted as of the first commit. One other odd thing that occurs. The log message "saved FrameOrder #, "
appears all at once, not as the transaction come in via the MessageQueue-MDB.


Also, I receive an Duplicate key exception from the DB upon commit of the Orders which have already been persisted. Also, even though my SessionFactory has 0 for the batch size. It appears as though the
commits are happening in batch mode. Which would explain why different threads can't see the order
via the hibSess.get().


Could someone please tell me what in the world is going on here. Thanks in advance.

DB Version:
MySQL 5.0.41
mysql jdbc connector 5.05


Top
 Profile  
 
 Post subject: My config factory file, and additional notes
PostPosted: Thu Jun 21, 2007 2:43 pm 
Newbie

Joined: Mon May 14, 2007 12:13 pm
Posts: 8
hibernate config file:

<session-factory>

<property name="hibernate.connection.datasource">java:/MYSQLDS1</property>
<property name="hibernate.connection.isolation">2</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
<property name="hibernate.connection.autocommit">false</property>
<property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
<property name="hibernate.order_updates">true</property>
<property name="hibernate.cache.use_second_level_cache">false</property>
<property name="hibernate.jdbc.use_streams_for_binary">true</property>
<property name="hibernate.current_session_context_class">jta</property>
<property name="hibernate.jdbc.batch_size">0</property>
<!-- JDBC connection pool (use the built-in) -->

<property name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
<property name="jta.UserTransaction">java:comp/UserTransaction</property>



<property name="hibernate.show_sql">false</property>
<property name="hibernate.format_sql">false</property>
<property name="hibernate.use_sql_comments">true</property>

<property name="connection.autoReconnect">true</property>
<property name="connection.autoReconnectForPools">true</property>
<property name="connection.pool_size">5</property>
<property name="idle-timeout-minutes">3</property>
<property name="hibernate.cglib.use_reflection_optimizer">false</property>

</session-factory>



One additional note.
The version of MySQL that we are using, is the 64bit version tuned for the AMD Opteron.


Thanks in advance for any help.


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.